mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-12-25 16:18:51 +01:00
Address deprecation warnings to be compatible with Django 2.0
This commit is contained in:
parent
f91762d4cd
commit
5112f0dfd0
@ -14,9 +14,9 @@ def protect_view(view_func):
|
||||
"""
|
||||
@wraps(view_func, assigned=available_attrs(view_func))
|
||||
def _wrapped_view(request, *args, **kwargs):
|
||||
if not request.user.is_authenticated() and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT:
|
||||
if not request.user.is_authenticated and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT:
|
||||
return HttpResponseRedirect(reverse('helpdesk:login'))
|
||||
elif not request.user.is_authenticated() and helpdesk_settings.HELPDESK_ANON_ACCESS_RAISES_404:
|
||||
elif not request.user.is_authenticated and helpdesk_settings.HELPDESK_ANON_ACCESS_RAISES_404:
|
||||
raise Http404
|
||||
return view_func(request, *args, **kwargs)
|
||||
|
||||
|
@ -374,7 +374,10 @@ def ticket_from_message(message, queue, logger):
|
||||
non_b64_err = TypeError
|
||||
try:
|
||||
logger.debug("Try to base64 decode the attachment payload")
|
||||
payloadToWrite = base64.decodestring(payload)
|
||||
if six.PY2:
|
||||
payloadToWrite = base64.decodestring(payload)
|
||||
else:
|
||||
payloadToWrite = base64.decodebytes(payload)
|
||||
except non_b64_err:
|
||||
logger.debug("Payload was not base64 encoded, using raw bytes")
|
||||
payloadToWrite = payload
|
||||
|
@ -140,7 +140,7 @@ class Migration(migrations.Migration):
|
||||
('votes', models.IntegerField(verbose_name='Votes', default=0, help_text='Total number of votes cast for this item')),
|
||||
('recommendations', models.IntegerField(verbose_name='Positive Votes', default=0, help_text='Number of votes for this item which were POSITIVE.')),
|
||||
('last_updated', models.DateTimeField(verbose_name='Last Updated', blank=True, help_text='The date on which this question was most recently changed.')),
|
||||
('category', models.ForeignKey(verbose_name='Category', to='helpdesk.KBCategory')),
|
||||
('category', models.ForeignKey(verbose_name='Category', to='helpdesk.KBCategory', on_delete=models.CASCADE)),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Knowledge base items',
|
||||
@ -203,7 +203,7 @@ class Migration(migrations.Migration):
|
||||
('title', models.CharField(verbose_name='Query Name', help_text='User-provided name for this query', max_length=100)),
|
||||
('shared', models.BooleanField(verbose_name='Shared With Other Users?', default=False, help_text='Should other users see this query?')),
|
||||
('query', models.TextField(verbose_name='Search Query', help_text='Pickled query object. Be wary changing this.')),
|
||||
('user', models.ForeignKey(verbose_name='User', to=settings.AUTH_USER_MODEL)),
|
||||
('user', models.ForeignKey(verbose_name='User', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Saved searches',
|
||||
@ -226,8 +226,8 @@ class Migration(migrations.Migration):
|
||||
('priority', models.IntegerField(verbose_name='Priority', help_text='1 = Highest Priority, 5 = Low Priority', blank=3, default=3, choices=[(1, '1. Critical'), (2, '2. High'), (3, '3. Normal'), (4, '4. Low'), (5, '5. Very Low')])),
|
||||
('due_date', models.DateTimeField(null=True, verbose_name='Due on', blank=True)),
|
||||
('last_escalation', models.DateTimeField(editable=False, null=True, blank=True, help_text='The date this ticket was last escalated - updated automatically by management/commands/escalate_tickets.py.')),
|
||||
('assigned_to', models.ForeignKey(null=True, verbose_name='Assigned to', blank=True, related_name='assigned_to', to=settings.AUTH_USER_MODEL)),
|
||||
('queue', models.ForeignKey(verbose_name='Queue', to='helpdesk.Queue')),
|
||||
('assigned_to', models.ForeignKey(null=True, verbose_name='Assigned to', blank=True, related_name='assigned_to', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
|
||||
('queue', models.ForeignKey(verbose_name='Queue', to='helpdesk.Queue', on_delete=models.CASCADE)),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Tickets',
|
||||
@ -244,8 +244,8 @@ class Migration(migrations.Migration):
|
||||
('email', models.EmailField(null=True, verbose_name='E-Mail Address', help_text='For non-user followers, enter their e-mail address', blank=True, max_length=75)),
|
||||
('can_view', models.BooleanField(verbose_name='Can View Ticket?', default=False, help_text='Can this CC login to view the ticket details?')),
|
||||
('can_update', models.BooleanField(verbose_name='Can Update Ticket?', default=False, help_text='Can this CC login and update the ticket?')),
|
||||
('ticket', models.ForeignKey(verbose_name='Ticket', to='helpdesk.Ticket')),
|
||||
('user', models.ForeignKey(null=True, verbose_name='User', blank=True, to=settings.AUTH_USER_MODEL, help_text='User who wishes to receive updates for this ticket.')),
|
||||
('ticket', models.ForeignKey(verbose_name='Ticket', to='helpdesk.Ticket', on_delete=models.CASCADE)),
|
||||
('user', models.ForeignKey(null=True, verbose_name='User', blank=True, to=settings.AUTH_USER_MODEL, help_text='User who wishes to receive updates for this ticket.', on_delete=models.CASCADE)),
|
||||
],
|
||||
options={
|
||||
},
|
||||
@ -258,7 +258,7 @@ class Migration(migrations.Migration):
|
||||
('field', models.CharField(verbose_name='Field', max_length=100)),
|
||||
('old_value', models.TextField(null=True, verbose_name='Old Value', blank=True)),
|
||||
('new_value', models.TextField(null=True, verbose_name='New Value', blank=True)),
|
||||
('followup', models.ForeignKey(verbose_name='Follow-up', to='helpdesk.FollowUp')),
|
||||
('followup', models.ForeignKey(verbose_name='Follow-up', to='helpdesk.FollowUp', on_delete=models.CASCADE)),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Ticket changes',
|
||||
@ -271,8 +271,8 @@ class Migration(migrations.Migration):
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)),
|
||||
('value', models.TextField(null=True, blank=True)),
|
||||
('field', models.ForeignKey(verbose_name='Field', to='helpdesk.CustomField')),
|
||||
('ticket', models.ForeignKey(verbose_name='Ticket', to='helpdesk.Ticket')),
|
||||
('field', models.ForeignKey(verbose_name='Field', to='helpdesk.CustomField', on_delete=models.CASCADE)),
|
||||
('ticket', models.ForeignKey(verbose_name='Ticket', to='helpdesk.Ticket', on_delete=models.CASCADE)),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Ticket custom field values',
|
||||
@ -284,8 +284,8 @@ class Migration(migrations.Migration):
|
||||
name='TicketDependency',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)),
|
||||
('depends_on', models.ForeignKey(related_name='depends_on', verbose_name='Depends On Ticket', to='helpdesk.Ticket')),
|
||||
('ticket', models.ForeignKey(related_name='ticketdependency', verbose_name='Ticket', to='helpdesk.Ticket')),
|
||||
('depends_on', models.ForeignKey(related_name='depends_on', verbose_name='Depends On Ticket', to='helpdesk.Ticket', on_delete=models.CASCADE)),
|
||||
('ticket', models.ForeignKey(related_name='ticketdependency', verbose_name='Ticket', to='helpdesk.Ticket', on_delete=models.CASCADE)),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Ticket dependencies',
|
||||
@ -298,7 +298,7 @@ class Migration(migrations.Migration):
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)),
|
||||
('settings_pickled', models.TextField(null=True, verbose_name='Settings Dictionary', blank=True, help_text='This is a base64-encoded representation of a pickled Python dictionary. Do not change this field via the admin.')),
|
||||
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
|
||||
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'User Settings',
|
||||
@ -325,13 +325,13 @@ class Migration(migrations.Migration):
|
||||
migrations.AddField(
|
||||
model_name='followup',
|
||||
name='ticket',
|
||||
field=models.ForeignKey(verbose_name='Ticket', to='helpdesk.Ticket'),
|
||||
field=models.ForeignKey(verbose_name='Ticket', to='helpdesk.Ticket', on_delete=models.CASCADE),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='followup',
|
||||
name='user',
|
||||
field=models.ForeignKey(null=True, verbose_name='User', blank=True, to=settings.AUTH_USER_MODEL),
|
||||
field=models.ForeignKey(null=True, verbose_name='User', blank=True, to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AddField(
|
||||
@ -343,7 +343,7 @@ class Migration(migrations.Migration):
|
||||
migrations.AddField(
|
||||
model_name='attachment',
|
||||
name='followup',
|
||||
field=models.ForeignKey(verbose_name='Follow-up', to='helpdesk.FollowUp'),
|
||||
field=models.ForeignKey(verbose_name='Follow-up', to='helpdesk.FollowUp', on_delete=models.CASCADE),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
||||
|
@ -18,7 +18,7 @@ class Migration(migrations.Migration):
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('queues', models.ManyToManyField(to='helpdesk.Queue', verbose_name='Authorized Queues')),
|
||||
('user', models.OneToOneField(verbose_name='User', to=settings.AUTH_USER_MODEL)),
|
||||
('user', models.OneToOneField(verbose_name='User', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Queue Membership',
|
||||
|
@ -15,6 +15,8 @@ class Migration(migrations.Migration):
|
||||
migrations.AlterField(
|
||||
model_name='usersettings',
|
||||
name='user',
|
||||
field=models.OneToOneField(to=settings.AUTH_USER_MODEL, related_name='usersettings_helpdesk'),
|
||||
field=models.OneToOneField(to=settings.AUTH_USER_MODEL,
|
||||
related_name='usersettings_helpdesk',
|
||||
on_delete=models.CASCADE),
|
||||
),
|
||||
]
|
||||
|
@ -255,11 +255,11 @@ class Queue(models.Model):
|
||||
|
||||
default_owner = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.SET_NULL,
|
||||
related_name='default_owner',
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name=_('Default owner'),
|
||||
on_delete=models.SET_NULL,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
@ -387,6 +387,7 @@ class Ticket(models.Model):
|
||||
|
||||
queue = models.ForeignKey(
|
||||
Queue,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_('Queue'),
|
||||
)
|
||||
|
||||
@ -412,6 +413,7 @@ class Ticket(models.Model):
|
||||
|
||||
assigned_to = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='assigned_to',
|
||||
blank=True,
|
||||
null=True,
|
||||
@ -628,6 +630,7 @@ class FollowUp(models.Model):
|
||||
|
||||
ticket = models.ForeignKey(
|
||||
Ticket,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_('Ticket'),
|
||||
)
|
||||
|
||||
@ -659,6 +662,7 @@ class FollowUp(models.Model):
|
||||
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.CASCADE,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name=_('User'),
|
||||
@ -701,6 +705,7 @@ class TicketChange(models.Model):
|
||||
|
||||
followup = models.ForeignKey(
|
||||
FollowUp,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_('Follow-up'),
|
||||
)
|
||||
|
||||
@ -763,6 +768,7 @@ class Attachment(models.Model):
|
||||
|
||||
followup = models.ForeignKey(
|
||||
FollowUp,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_('Follow-up'),
|
||||
)
|
||||
|
||||
@ -976,6 +982,7 @@ class KBItem(models.Model):
|
||||
"""
|
||||
category = models.ForeignKey(
|
||||
KBCategory,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_('Category'),
|
||||
)
|
||||
|
||||
@ -1049,6 +1056,7 @@ class SavedSearch(models.Model):
|
||||
"""
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_('User'),
|
||||
)
|
||||
|
||||
@ -1093,6 +1101,7 @@ class UserSettings(models.Model):
|
||||
|
||||
user = models.OneToOneField(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="usersettings_helpdesk")
|
||||
|
||||
settings_pickled = models.TextField(
|
||||
@ -1251,11 +1260,13 @@ class TicketCC(models.Model):
|
||||
|
||||
ticket = models.ForeignKey(
|
||||
Ticket,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_('Ticket'),
|
||||
)
|
||||
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.CASCADE,
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text=_('User who wishes to receive updates for this ticket.'),
|
||||
@ -1425,11 +1436,13 @@ class CustomField(models.Model):
|
||||
class TicketCustomFieldValue(models.Model):
|
||||
ticket = models.ForeignKey(
|
||||
Ticket,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_('Ticket'),
|
||||
)
|
||||
|
||||
field = models.ForeignKey(
|
||||
CustomField,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_('Field'),
|
||||
)
|
||||
|
||||
@ -1458,12 +1471,14 @@ class TicketDependency(models.Model):
|
||||
|
||||
ticket = models.ForeignKey(
|
||||
Ticket,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_('Ticket'),
|
||||
related_name='ticketdependency',
|
||||
)
|
||||
|
||||
depends_on = models.ForeignKey(
|
||||
Ticket,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_('Depends On Ticket'),
|
||||
related_name='depends_on',
|
||||
)
|
||||
|
@ -92,7 +92,7 @@ class GetEmailParametricTemplate(object):
|
||||
|
||||
if self.socks:
|
||||
from socks import ProxyConnectionError
|
||||
with self.assertRaisesRegexp(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
|
||||
with self.assertRaisesRegex(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
|
||||
call_command('get_email')
|
||||
|
||||
else:
|
||||
@ -165,7 +165,7 @@ class GetEmailParametricTemplate(object):
|
||||
|
||||
if self.socks:
|
||||
from socks import ProxyConnectionError
|
||||
with self.assertRaisesRegexp(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
|
||||
with self.assertRaisesRegex(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
|
||||
call_command('get_email')
|
||||
|
||||
else:
|
||||
@ -278,7 +278,7 @@ class GetEmailParametricTemplate(object):
|
||||
|
||||
if self.socks:
|
||||
from socks import ProxyConnectionError
|
||||
with self.assertRaisesRegexp(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
|
||||
with self.assertRaisesRegex(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
|
||||
call_command('get_email')
|
||||
|
||||
else:
|
||||
@ -525,7 +525,7 @@ a9eiiQ+3V1v+7wWHXCzq
|
||||
|
||||
if self.socks:
|
||||
from socks import ProxyConnectionError
|
||||
with self.assertRaisesRegexp(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
|
||||
with self.assertRaisesRegex(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
|
||||
call_command('get_email')
|
||||
|
||||
else:
|
||||
|
@ -23,7 +23,7 @@ from helpdesk.models import Ticket, Queue, UserSettings, KBCategory
|
||||
@protect_view
|
||||
def homepage(request):
|
||||
if request.user.is_staff or \
|
||||
(request.user.is_authenticated() and
|
||||
(request.user.is_authenticated and
|
||||
helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE):
|
||||
try:
|
||||
if request.user.usersettings_helpdesk.settings.get('login_view_ticketlist', False):
|
||||
@ -61,7 +61,7 @@ def homepage(request):
|
||||
if queue:
|
||||
initial_data['queue'] = queue.id
|
||||
|
||||
if request.user.is_authenticated() and request.user.email:
|
||||
if request.user.is_authenticated and request.user.email:
|
||||
initial_data['submitter_email'] = request.user.email
|
||||
|
||||
form = PublicTicketForm(initial=initial_data)
|
||||
|
@ -46,14 +46,14 @@ User = get_user_model()
|
||||
if helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE:
|
||||
# treat 'normal' users like 'staff'
|
||||
staff_member_required = user_passes_test(
|
||||
lambda u: u.is_authenticated() and u.is_active)
|
||||
lambda u: u.is_authenticated and u.is_active)
|
||||
else:
|
||||
staff_member_required = user_passes_test(
|
||||
lambda u: u.is_authenticated() and u.is_active and u.is_staff)
|
||||
lambda u: u.is_authenticated and u.is_active and u.is_staff)
|
||||
|
||||
|
||||
superuser_required = user_passes_test(
|
||||
lambda u: u.is_authenticated() and u.is_active and u.is_superuser)
|
||||
lambda u: u.is_authenticated and u.is_active and u.is_superuser)
|
||||
|
||||
|
||||
def _get_user_queues(user):
|
||||
@ -387,7 +387,7 @@ def subscribe_staff_member_to_ticket(ticket, user):
|
||||
|
||||
def update_ticket(request, ticket_id, public=False):
|
||||
if not (public or (
|
||||
request.user.is_authenticated() and
|
||||
request.user.is_authenticated and
|
||||
request.user.is_active and (
|
||||
request.user.is_staff or
|
||||
helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE))):
|
||||
@ -644,7 +644,7 @@ def update_ticket(request, ticket_id, public=False):
|
||||
ticket.save()
|
||||
|
||||
# auto subscribe user if enabled
|
||||
if helpdesk_settings.HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE and request.user.is_authenticated():
|
||||
if helpdesk_settings.HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE and request.user.is_authenticated:
|
||||
ticketcc_string, SHOW_SUBSCRIBE = return_ticketccstring_and_show_subscribe(request.user, ticket)
|
||||
if SHOW_SUBSCRIBE:
|
||||
subscribe_staff_member_to_ticket(ticket, request.user)
|
||||
|
@ -29,7 +29,8 @@ class QuickDjangoTest(object):
|
||||
'django.contrib.staticfiles',
|
||||
'bootstrapform',
|
||||
)
|
||||
MIDDLEWARE_CLASSES = [
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
@ -78,7 +79,7 @@ class QuickDjangoTest(object):
|
||||
}
|
||||
},
|
||||
INSTALLED_APPS=self.INSTALLED_APPS + self.apps,
|
||||
MIDDLEWARE_CLASSES=self.MIDDLEWARE_CLASSES,
|
||||
MIDDLEWARE=self.MIDDLEWARE,
|
||||
ROOT_URLCONF='helpdesk.tests.urls',
|
||||
STATIC_URL='/static/',
|
||||
TEMPLATES=self.TEMPLATES
|
||||
|
Loading…
Reference in New Issue
Block a user