From 52d7d6db45cc64fcd4f01d65c11c4dd456c5c174 Mon Sep 17 00:00:00 2001 From: Nick McCullum Date: Wed, 16 Mar 2022 18:57:50 -0400 Subject: [PATCH 1/9] Update requirements file --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 2bba41d2..4ffa8471 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Django>=2.2,<4 +Django>=2.2 django-bootstrap4-form celery django-celery-beat From 564a4539f0f30be260eacc52775dffcb844e52f2 Mon Sep 17 00:00:00 2001 From: Nick McCullum Date: Wed, 16 Mar 2022 19:15:23 -0400 Subject: [PATCH 2/9] Updated requirements to be Django 4 compatible --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4ffa8471..771eab70 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ Django>=2.2 django-bootstrap4-form celery -django-celery-beat +-e git+ssh://git@github.com/celery/django-celery-beat.git@master#egg=django-celery-beat email-reply-parser akismet markdown From 80a4c0547512bffc7929a04ffbbda6d497ac2ae7 Mon Sep 17 00:00:00 2001 From: Nick McCullum Date: Wed, 16 Mar 2022 19:17:49 -0400 Subject: [PATCH 3/9] another try --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 771eab70..768b1734 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ Django>=2.2 django-bootstrap4-form celery --e git+ssh://git@github.com/celery/django-celery-beat.git@master#egg=django-celery-beat +-e git+ssh://git@github.com/celery/django-celery-beat.git@master#egg=django_celery_beat email-reply-parser akismet markdown From e7fd06da53cd3800598d834d6b8b300523305c35 Mon Sep 17 00:00:00 2001 From: Nick McCullum Date: Wed, 16 Mar 2022 19:25:29 -0400 Subject: [PATCH 4/9] Some requirements fixes --- requirements.txt | 1 - setup.py | 76 ++++++++++++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/requirements.txt b/requirements.txt index 768b1734..97472289 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ Django>=2.2 django-bootstrap4-form celery --e git+ssh://git@github.com/celery/django-celery-beat.git@master#egg=django_celery_beat email-reply-parser akismet markdown diff --git a/setup.py b/setup.py index 916bb729..838af34b 100644 --- a/setup.py +++ b/setup.py @@ -4,13 +4,20 @@ from distutils.util import convert_path from fnmatch import fnmatchcase from setuptools import setup, find_packages -version = '0.3.2' +version = "0.3.2" # Provided as an attribute, so you can append to these instead # of replicating them: -standard_exclude = ('*.py', '*.pyc', '*$py.class', '*~', '.*', '*.bak') -standard_exclude_directories = ('.*', 'CVS', '_darcs', './build', - './dist', 'EGG-INFO', '*.egg-info') +standard_exclude = ("*.py", "*.pyc", "*$py.class", "*~", ".*", "*.bak") +standard_exclude_directories = ( + ".*", + "CVS", + "_darcs", + "./build", + "./dist", + "EGG-INFO", + "*.egg-info", +) # (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php @@ -18,11 +25,13 @@ standard_exclude_directories = ('.*', 'CVS', '_darcs', './build', # you can't import this from another package, when you don't know if # that package is installed yet. def find_package_data( - where='.', package='', + where=".", + package="", exclude=standard_exclude, exclude_directories=standard_exclude_directories, only_in_packages=True, - show_ignored=False): + show_ignored=False, +): """ Return a dictionary suitable for use in ``package_data`` in a distutils ``setup.py`` file. @@ -51,7 +60,7 @@ def find_package_data( """ out = {} - stack = [(convert_path(where), '', package, only_in_packages)] + stack = [(convert_path(where), "", package, only_in_packages)] while stack: where, prefix, package, only_in_packages = stack.pop(0) for name in os.listdir(where): @@ -59,43 +68,40 @@ def find_package_data( if os.path.isdir(fn): bad_name = False for pattern in exclude_directories: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if fnmatchcase(name, pattern) or fn.lower() == pattern.lower(): bad_name = True if show_ignored: print( "Directory %s ignored by pattern %s" % (fn, pattern), - file=sys.stderr + file=sys.stderr, ) break if bad_name: continue - if (os.path.isfile(os.path.join(fn, '__init__.py')) - and not prefix): + if os.path.isfile(os.path.join(fn, "__init__.py")) and not prefix: if not package: new_package = name else: - new_package = package + '.' + name - stack.append((fn, '', new_package, False)) + new_package = package + "." + name + stack.append((fn, "", new_package, False)) else: - stack.append((fn, prefix + name + '/', package, only_in_packages)) + stack.append((fn, prefix + name + "/", package, only_in_packages)) elif package or not only_in_packages: # is a file bad_name = False for pattern in exclude: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if fnmatchcase(name, pattern) or fn.lower() == pattern.lower(): bad_name = True if show_ignored: print( "File %s ignored by pattern %s" % (fn, pattern), - file=sys.stderr - ) + file=sys.stderr, + ) break if bad_name: continue - out.setdefault(package, []).append(prefix+name) + out.setdefault(package, []).append(prefix + name) return out @@ -116,7 +122,7 @@ def get_long_description(): setup( - name='django-helpdesk', + name="django-helpdesk", version=version, description="Django-powered ticket tracker for your helpdesk", long_description=get_long_description(), @@ -128,7 +134,7 @@ setup( "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Framework :: Django", - 'Framework :: Django :: 2.2', + "Framework :: Django :: 2.2", "Framework :: Django :: 3.2", "Environment :: Web Environment", "Operating System :: OS Independent", @@ -139,18 +145,26 @@ setup( "Topic :: Office/Business", "Natural Language :: English", ], - keywords=['django', 'helpdesk', 'django-helpdesk', 'tickets', 'incidents', - 'cases', 'bugs', 'track', 'support'], - author='Ross Poulton', - author_email='ross@rossp.org', - maintainer='Garret Wassermann', - maintainer_email='gwasser@gmail.com', - url='https://github.com/django-helpdesk/django-helpdesk', - license='BSD', + keywords=[ + "django", + "helpdesk", + "django-helpdesk", + "tickets", + "incidents", + "cases", + "bugs", + "track", + "support", + ], + author="Ross Poulton", + author_email="ross@rossp.org", + maintainer="Garret Wassermann", + maintainer_email="gwasser@gmail.com", + url="https://github.com/django-helpdesk/django-helpdesk", + license="BSD", packages=find_packages(), package_data=find_package_data("helpdesk", only_in_packages=False), include_package_data=True, zip_safe=False, install_requires=get_requirements(), ) - From 358080926c1353a44bddb45bcf934a453132d8af Mon Sep 17 00:00:00 2001 From: Nick McCullum Date: Wed, 16 Mar 2022 22:29:09 -0400 Subject: [PATCH 5/9] Added Django 4 support. --- demo/demodesk/config/urls.py | 6 +- helpdesk/admin.py | 2 +- helpdesk/email.py | 12 +- helpdesk/forms.py | 2 +- helpdesk/lib.py | 10 +- .../commands/create_queue_permissions.py | 2 +- .../commands/create_usersettings.py | 2 +- .../management/commands/escalate_tickets.py | 2 +- .../0009_migrate_queuemembership.py | 2 +- helpdesk/models.py | 8 +- helpdesk/query.py | 2 +- helpdesk/tests/test_attachments.py | 4 +- helpdesk/tests/urls.py | 6 +- helpdesk/urls.py | 104 +++++++++--------- helpdesk/views/feeds.py | 2 +- helpdesk/views/public.py | 6 +- helpdesk/views/staff.py | 2 +- 17 files changed, 87 insertions(+), 87 deletions(-) diff --git a/demo/demodesk/config/urls.py b/demo/demodesk/config/urls.py index 0c37aac6..e4c9b48e 100644 --- a/demo/demodesk/config/urls.py +++ b/demo/demodesk/config/urls.py @@ -13,7 +13,7 @@ Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ -from django.conf.urls import url, include +from django.urls import include, path from django.contrib import admin from django.conf import settings from django.conf.urls.static import static @@ -26,6 +26,6 @@ from django.conf.urls.static import static # https://docs.djangoproject.com/en/1.10/howto/static-files/ urlpatterns = [ - url(r'^admin/', admin.site.urls), - url(r'^', include('helpdesk.urls', namespace='helpdesk')), + path('admin/', admin.site.urls), + path('', include('helpdesk.urls', namespace='helpdesk')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/helpdesk/admin.py b/helpdesk/admin.py index 9d18007e..339e02fb 100644 --- a/helpdesk/admin.py +++ b/helpdesk/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from helpdesk.models import Queue, Ticket, FollowUp, PreSetReply, KBCategory from helpdesk.models import EscalationExclusion, EmailTemplate, KBItem from helpdesk.models import TicketChange, KBIAttachment, FollowUpAttachment, IgnoreEmail diff --git a/helpdesk/email.py b/helpdesk/email.py index 998ebb96..537f9af4 100644 --- a/helpdesk/email.py +++ b/helpdesk/email.py @@ -27,7 +27,7 @@ from django.core.exceptions import ValidationError from django.core.files.uploadedfile import SimpleUploadedFile from django.db.models import Q from django.utils import encoding, timezone -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from email_reply_parser import EmailReplyParser from helpdesk import settings @@ -129,7 +129,7 @@ def pop3_sync(q, logger, server): if type(raw_content[0]) is bytes: full_message = "\n".join([elm.decode('utf-8') for elm in raw_content]) else: - full_message = encoding.force_text("\n".join(raw_content), errors='replace') + full_message = encoding.force_str("\n".join(raw_content), errors='replace') ticket = object_from_message(message=full_message, queue=q, logger=logger) if ticket: @@ -175,7 +175,7 @@ def imap_sync(q, logger, server): for num in msgnums: logger.info("Processing message %s" % num) status, data = server.fetch(num, '(RFC822)') - full_message = encoding.force_text(data[0][1], errors='replace') + full_message = encoding.force_str(data[0][1], errors='replace') try: ticket = object_from_message(message=full_message, queue=q, logger=logger) except TypeError: @@ -268,7 +268,7 @@ def process_queue(q, logger): for i, m in enumerate(mail, 1): logger.info("Processing message %d" % i) with open(m, 'r') as f: - full_message = encoding.force_text(f.read(), errors='replace') + full_message = encoding.force_str(f.read(), errors='replace') ticket = object_from_message(message=full_message, queue=q, logger=logger) if ticket: logger.info("Successfully processed message %d, ticket/comment created.", i) @@ -579,9 +579,9 @@ def object_from_message(message, queue, logger): logger.debug("Discovered plain text MIME part") else: try: - email_body = encoding.smart_text(part.get_payload(decode=True)) + email_body = encoding.smart_str(part.get_payload(decode=True)) except UnicodeDecodeError: - email_body = encoding.smart_text(part.get_payload(decode=False)) + email_body = encoding.smart_str(part.get_payload(decode=False)) if not body and not full_body: # no text has been parsed so far - try such deep parsing for some messages diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 377ad387..99a927f9 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -12,7 +12,7 @@ from datetime import datetime, date, time from django.core.exceptions import ObjectDoesNotExist, ValidationError from django import forms from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.contrib.auth import get_user_model from django.utils import timezone diff --git a/helpdesk/lib.py b/helpdesk/lib.py index da853990..9dd22bce 100644 --- a/helpdesk/lib.py +++ b/helpdesk/lib.py @@ -10,7 +10,7 @@ import logging import mimetypes from django.conf import settings -from django.utils.encoding import smart_text +from django.utils.encoding import smart_str from helpdesk.models import FollowUpAttachment @@ -117,13 +117,13 @@ def text_is_spam(text, request): if ak.verify_key(): ak_data = { 'user_ip': request.META.get('REMOTE_ADDR', '127.0.0.1'), - 'user_agent': request.META.get('HTTP_USER_AGENT', ''), - 'referrer': request.META.get('HTTP_REFERER', ''), + 'user_agent': request.headers.get('User-Agent', ''), + 'referrer': request.headers.get('Referer', ''), 'comment_type': 'comment', 'comment_author': '', } - return ak.comment_check(smart_text(text), data=ak_data) + return ak.comment_check(smart_str(text), data=ak_data) return False @@ -135,7 +135,7 @@ def process_attachments(followup, attached_files): for attached in attached_files: if attached.size: - filename = smart_text(attached.name) + filename = smart_str(attached.name) att = FollowUpAttachment( followup=followup, file=attached, diff --git a/helpdesk/management/commands/create_queue_permissions.py b/helpdesk/management/commands/create_queue_permissions.py index 50e980c3..fb72f3fe 100644 --- a/helpdesk/management/commands/create_queue_permissions.py +++ b/helpdesk/management/commands/create_queue_permissions.py @@ -19,7 +19,7 @@ from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType from django.core.management.base import BaseCommand, CommandError from django.db.utils import IntegrityError -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from helpdesk.models import Queue diff --git a/helpdesk/management/commands/create_usersettings.py b/helpdesk/management/commands/create_usersettings.py index e27cea16..2ed628a1 100644 --- a/helpdesk/management/commands/create_usersettings.py +++ b/helpdesk/management/commands/create_usersettings.py @@ -8,7 +8,7 @@ create_usersettings.py - Easy way to create helpdesk-specific settings for users who don't yet have them. """ -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.core.management.base import BaseCommand from django.contrib.auth import get_user_model diff --git a/helpdesk/management/commands/escalate_tickets.py b/helpdesk/management/commands/escalate_tickets.py index edbf7307..07c9a1c4 100644 --- a/helpdesk/management/commands/escalate_tickets.py +++ b/helpdesk/management/commands/escalate_tickets.py @@ -15,7 +15,7 @@ import sys from django.core.management.base import BaseCommand, CommandError from django.db.models import Q -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.utils import timezone from helpdesk.models import Queue, Ticket, FollowUp, EscalationExclusion, TicketChange diff --git a/helpdesk/migrations/0009_migrate_queuemembership.py b/helpdesk/migrations/0009_migrate_queuemembership.py index 09e2a60f..318b24ab 100644 --- a/helpdesk/migrations/0009_migrate_queuemembership.py +++ b/helpdesk/migrations/0009_migrate_queuemembership.py @@ -2,7 +2,7 @@ from django.core.exceptions import ObjectDoesNotExist from django.db import migrations from django.db.utils import IntegrityError -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ def create_and_assign_permissions(apps, schema_editor): diff --git a/helpdesk/models.py b/helpdesk/models.py index f8ffb8b1..67a792d4 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -14,7 +14,7 @@ from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.db import models from django.conf import settings from django.utils import timezone -from django.utils.translation import ugettext_lazy as _, ugettext +from django.utils.translation import gettext_lazy as _, gettext from io import StringIO import re import os @@ -1007,11 +1007,11 @@ class TicketChange(models.Model): def __str__(self): out = '%s ' % self.field if not self.new_value: - out += ugettext('removed') + out += gettext('removed') elif not self.old_value: - out += ugettext('set to %s') % self.new_value + out += gettext('set to %s') % self.new_value else: - out += ugettext('changed from "%(old_value)s" to "%(new_value)s"') % { + out += gettext('changed from "%(old_value)s" to "%(new_value)s"') % { 'old_value': self.old_value, 'new_value': self.new_value } diff --git a/helpdesk/query.py b/helpdesk/query.py index 36d7eca2..c347c406 100644 --- a/helpdesk/query.py +++ b/helpdesk/query.py @@ -1,7 +1,7 @@ from django.db.models import Q from django.urls import reverse from django.utils.html import escape -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from base64 import b64encode from base64 import b64decode diff --git a/helpdesk/tests/test_attachments.py b/helpdesk/tests/test_attachments.py index 942a2353..3f65dc0a 100644 --- a/helpdesk/tests/test_attachments.py +++ b/helpdesk/tests/test_attachments.py @@ -2,7 +2,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile from django.urls import reverse from django.test import override_settings, TestCase -from django.utils.encoding import smart_text +from django.utils.encoding import smart_str from helpdesk import lib, models @@ -78,7 +78,7 @@ class AttachmentIntegrationTests(TestCase): # Ensure attachment is available with correct content att = models.FollowUpAttachment.objects.get(followup__ticket=response.context['ticket']) with open(os.path.join(MEDIA_DIR, att.file.name)) as file_on_disk: - disk_content = smart_text(file_on_disk.read(), 'utf-8') + disk_content = smart_str(file_on_disk.read(), 'utf-8') self.assertEqual(disk_content, 'โจ') diff --git a/helpdesk/tests/urls.py b/helpdesk/tests/urls.py index 640937c2..252441f3 100644 --- a/helpdesk/tests/urls.py +++ b/helpdesk/tests/urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import include, url +from django.urls import include, path from django.contrib import admin urlpatterns = [ - url(r'^helpdesk/', include('helpdesk.urls', namespace='helpdesk')), - url(r'^admin/', admin.site.urls), + path('helpdesk/', include('helpdesk.urls', namespace='helpdesk')), + path('admin/', admin.site.urls), ] diff --git a/helpdesk/urls.py b/helpdesk/urls.py index 6959a99b..7e55f280 100644 --- a/helpdesk/urls.py +++ b/helpdesk/urls.py @@ -7,7 +7,7 @@ urls.py - Mapping of URL's to our various views. Note we always used NAMED views for simplicity in linking later on. """ -from django.conf.urls import url +from django.urls import path, re_path from django.contrib.auth.decorators import login_required from django.contrib.auth import views as auth_views from django.views.generic import TemplateView @@ -41,195 +41,195 @@ app_name = 'helpdesk' base64_pattern = r'(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$' urlpatterns = [ - url(r'^dashboard/$', + path('dashboard/', staff.dashboard, name='dashboard'), - url(r'^tickets/$', + path('tickets/', staff.ticket_list, name='list'), - url(r'^tickets/update/$', + path('tickets/update/', staff.mass_update, name='mass_update'), - url(r'^tickets/merge$', + path('tickets/merge', staff.merge_tickets, name='merge_tickets'), - url(r'^tickets/(?P[0-9]+)/$', + path('tickets//', staff.view_ticket, name='view'), - url(r'^tickets/(?P[0-9]+)/followup_edit/(?P[0-9]+)/$', + path('tickets//followup_edit//', staff.followup_edit, name='followup_edit'), - url(r'^tickets/(?P[0-9]+)/followup_delete/(?P[0-9]+)/$', + path('tickets//followup_delete//', staff.followup_delete, name='followup_delete'), - url(r'^tickets/(?P[0-9]+)/edit/$', + path('tickets//edit/', staff.edit_ticket, name='edit'), - url(r'^tickets/(?P[0-9]+)/update/$', + path('tickets//update/', staff.update_ticket, name='update'), - url(r'^tickets/(?P[0-9]+)/delete/$', + path('tickets//delete/', staff.delete_ticket, name='delete'), - url(r'^tickets/(?P[0-9]+)/hold/$', + path('tickets//hold/', staff.hold_ticket, name='hold'), - url(r'^tickets/(?P[0-9]+)/unhold/$', + path('tickets//unhold/', staff.unhold_ticket, name='unhold'), - url(r'^tickets/(?P[0-9]+)/cc/$', + path('tickets//cc/', staff.ticket_cc, name='ticket_cc'), - url(r'^tickets/(?P[0-9]+)/cc/add/$', + path('tickets//cc/add/', staff.ticket_cc_add, name='ticket_cc_add'), - url(r'^tickets/(?P[0-9]+)/cc/delete/(?P[0-9]+)/$', + path('tickets//cc/delete//', staff.ticket_cc_del, name='ticket_cc_del'), - url(r'^tickets/(?P[0-9]+)/dependency/add/$', + path('tickets//dependency/add/', staff.ticket_dependency_add, name='ticket_dependency_add'), - url(r'^tickets/(?P[0-9]+)/dependency/delete/(?P[0-9]+)/$', + path('tickets//dependency/delete//', staff.ticket_dependency_del, name='ticket_dependency_del'), - url(r'^tickets/(?P[0-9]+)/attachment_delete/(?P[0-9]+)/$', + path('tickets//attachment_delete//', staff.attachment_del, name='attachment_del'), - url(r'^raw/(?P\w+)/$', + re_path(r'^raw/(?P\w+)/$', staff.raw_details, name='raw'), - url(r'^rss/$', + path('rss/', staff.rss_list, name='rss_index'), - url(r'^reports/$', + path('reports/', staff.report_index, name='report_index'), - url(r'^reports/(?P\w+)/$', + re_path(r'^reports/(?P\w+)/$', staff.run_report, name='run_report'), - url(r'^save_query/$', + path('save_query/', staff.save_query, name='savequery'), - url(r'^delete_query/(?P[0-9]+)/$', + path('delete_query//', staff.delete_saved_query, name='delete_query'), - url(r'^settings/$', + path('settings/', staff.EditUserSettingsView.as_view(), name='user_settings'), - url(r'^ignore/$', + path('ignore/', staff.email_ignore, name='email_ignore'), - url(r'^ignore/add/$', + path('ignore/add/', staff.email_ignore_add, name='email_ignore_add'), - url(r'^ignore/delete/(?P[0-9]+)/$', + path('ignore/delete//', staff.email_ignore_del, name='email_ignore_del'), - url(r'^datatables_ticket_list/(?P{})$'.format(base64_pattern), + re_path(r'^datatables_ticket_list/(?P{})$'.format(base64_pattern), staff.datatables_ticket_list, name="datatables_ticket_list"), - url(r'^timeline_ticket_list/(?P{})$'.format(base64_pattern), + re_path(r'^timeline_ticket_list/(?P{})$'.format(base64_pattern), staff.timeline_ticket_list, name="timeline_ticket_list"), ] urlpatterns += [ - url(r'^$', + path('', protect_view(public.Homepage.as_view()), name='home'), - url(r'^tickets/submit/$', + path('tickets/submit/', public.create_ticket, name='submit'), - url(r'^tickets/submit_iframe/$', + path('tickets/submit_iframe/', public.CreateTicketIframeView.as_view(), name='submit_iframe'), - url(r'^tickets/success_iframe/$', # Ticket was submitted successfully + path('tickets/success_iframe/', # Ticket was submitted successfully public.SuccessIframeView.as_view(), name='success_iframe'), - url(r'^view/$', + path('view/', public.view_ticket, name='public_view'), - url(r'^change_language/$', + path('change_language/', public.change_language, name='public_change_language'), ] urlpatterns += [ - url(r'^rss/user/(?P[^/]+)/$', + path('rss/user//', helpdesk_staff_member_required(feeds.OpenTicketsByUser()), name='rss_user'), - url(r'^rss/user/(?P[^/]+)/(?P[A-Za-z0-9_-]+)/$', + re_path(r'^rss/user/(?P[^/]+)/(?P[A-Za-z0-9_-]+)/$', helpdesk_staff_member_required(feeds.OpenTicketsByUser()), name='rss_user_queue'), - url(r'^rss/queue/(?P[A-Za-z0-9_-]+)/$', + re_path(r'^rss/queue/(?P[A-Za-z0-9_-]+)/$', helpdesk_staff_member_required(feeds.OpenTicketsByQueue()), name='rss_queue'), - url(r'^rss/unassigned/$', + path('rss/unassigned/', helpdesk_staff_member_required(feeds.UnassignedTickets()), name='rss_unassigned'), - url(r'^rss/recent_activity/$', + path('rss/recent_activity/', helpdesk_staff_member_required(feeds.RecentFollowUps()), name='rss_activity'), ] urlpatterns += [ - url(r'^login/$', + path('login/', login.login, name='login'), - url(r'^logout/$', + path('logout/', auth_views.LogoutView.as_view( template_name='helpdesk/registration/login.html', next_page='../'), name='logout'), - url(r'^password_change/$', + path('password_change/', auth_views.PasswordChangeView.as_view( template_name='helpdesk/registration/change_password.html', success_url='./done'), name='password_change'), - url(r'^password_change/done$', + path('password_change/done', auth_views.PasswordChangeDoneView.as_view( template_name='helpdesk/registration/change_password_done.html',), name='password_change_done'), @@ -237,29 +237,29 @@ urlpatterns += [ if helpdesk_settings.HELPDESK_KB_ENABLED: urlpatterns += [ - url(r'^kb/$', + path('kb/', kb.index, name='kb_index'), - url(r'^kb/(?P[A-Za-z0-9_-]+)/$', + re_path(r'^kb/(?P[A-Za-z0-9_-]+)/$', kb.category, name='kb_category'), - url(r'^kb/(?P[0-9]+)/vote/$', + path('kb//vote/', kb.vote, name='kb_vote'), - url(r'^kb_iframe/(?P[A-Za-z0-9_-]+)/$', + re_path(r'^kb_iframe/(?P[A-Za-z0-9_-]+)/$', kb.category_iframe, name='kb_category_iframe'), ] urlpatterns += [ - url(r'^help/context/$', + path('help/context/', TemplateView.as_view(template_name='helpdesk/help_context.html'), name='help_context'), - url(r'^system_settings/$', + path('system_settings/', login_required(DirectTemplateView.as_view(template_name='helpdesk/system_settings.html')), name='system_settings'), ] diff --git a/helpdesk/views/feeds.py b/helpdesk/views/feeds.py index aca10630..7ae8ebcb 100644 --- a/helpdesk/views/feeds.py +++ b/helpdesk/views/feeds.py @@ -11,7 +11,7 @@ from django.contrib.auth import get_user_model from django.contrib.syndication.views import Feed from django.urls import reverse from django.db.models import Q -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.shortcuts import get_object_or_404 from helpdesk.models import Ticket, FollowUp, Queue diff --git a/helpdesk/views/public.py b/helpdesk/views/public.py index 779e8d6d..b0c97c24 100644 --- a/helpdesk/views/public.py +++ b/helpdesk/views/public.py @@ -15,8 +15,8 @@ from django.core.exceptions import ( from django.urls import reverse from django.http import HttpResponseRedirect from django.shortcuts import render -from django.utils.http import urlquote -from django.utils.translation import ugettext as _ +from urllib.parse import quote +from django.utils.translation import gettext as _ from django.conf import settings from django.views.decorators.clickjacking import xframe_options_exempt from django.views.decorators.csrf import csrf_exempt @@ -112,7 +112,7 @@ class BaseCreateTicketView(abstract_views.AbstractCreateTicketMixin, FormView): return HttpResponseRedirect('%s?ticket=%s&email=%s&key=%s' % ( reverse('helpdesk:public_view'), ticket.ticket_for_url, - urlquote(ticket.submitter_email), + quote(ticket.submitter_email), ticket.secret_key) ) except ValueError: diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 462b3540..bba76f32 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -19,7 +19,7 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.db.models import Q from django.http import HttpResponseRedirect, Http404, HttpResponse, JsonResponse from django.shortcuts import render, get_object_or_404, redirect -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.utils.html import escape from django.utils import timezone from django.views.decorators.csrf import requires_csrf_token From 9444d1592d9b91d0a7fc33e7e16b29ba9558b70f Mon Sep 17 00:00:00 2001 From: Nick McCullum Date: Fri, 1 Apr 2022 16:20:15 -0300 Subject: [PATCH 6/9] removed deprecated and template syntax --- .../templates/helpdesk/filters/owner.html | 2 +- .../templates/helpdesk/filters/sorting.html | 12 +++++------ .../helpdesk/public_view_ticket.html | 20 +++++++++---------- .../templates/helpdesk/report_output.html | 2 +- helpdesk/templates/helpdesk/ticket.html | 20 +++++++++---------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/helpdesk/templates/helpdesk/filters/owner.html b/helpdesk/templates/helpdesk/filters/owner.html index 20ed9446..0e7b64cc 100644 --- a/helpdesk/templates/helpdesk/filters/owner.html +++ b/helpdesk/templates/helpdesk/filters/owner.html @@ -14,7 +14,7 @@ {% endwith %} {% for u in user_choices %} {% endfor %} diff --git a/helpdesk/templates/helpdesk/filters/sorting.html b/helpdesk/templates/helpdesk/filters/sorting.html index b9295fad..9115b1ce 100644 --- a/helpdesk/templates/helpdesk/filters/sorting.html +++ b/helpdesk/templates/helpdesk/filters/sorting.html @@ -6,22 +6,22 @@
diff --git a/helpdesk/templates/helpdesk/public_view_ticket.html b/helpdesk/templates/helpdesk/public_view_ticket.html index 2d28c2f9..c293427d 100644 --- a/helpdesk/templates/helpdesk/public_view_ticket.html +++ b/helpdesk/templates/helpdesk/public_view_ticket.html @@ -99,34 +99,34 @@
{% trans "You can insert ticket and queue details in your message. For more information, see the context help page." %}
{% if not ticket.can_be_resolved %}
{% trans "This ticket cannot be resolved or closed until the tickets it depends on are resolved." %}
{% endif %} - {% ifequal ticket.status 1 %} + {% if ticket.status == 1 %} - {% endifequal %} - {% ifequal ticket.status 2 %} + {% endif %} + {% if ticket.status == 2 %}
- {% endifequal %} - {% ifequal ticket.status 3 %} + {% endif %} + {% if ticket.status == 3 %}
- {% endifequal %} - {% ifequal ticket.status 4 %} + {% endif %} + {% if ticket.status == 4 %}
- {% endifequal %} - {% ifequal ticket.status 5 %} + {% endif %} + {% if ticket.status == 5 %}
- {% endifequal %} + {% endif %} diff --git a/helpdesk/templates/helpdesk/report_output.html b/helpdesk/templates/helpdesk/report_output.html index 69497b03..cd50fe0b 100644 --- a/helpdesk/templates/helpdesk/report_output.html +++ b/helpdesk/templates/helpdesk/report_output.html @@ -29,7 +29,7 @@ diff --git a/helpdesk/templates/helpdesk/ticket.html b/helpdesk/templates/helpdesk/ticket.html index 5eade600..54324f3b 100644 --- a/helpdesk/templates/helpdesk/ticket.html +++ b/helpdesk/templates/helpdesk/ticket.html @@ -112,39 +112,39 @@
{% if not ticket.can_be_resolved %}
{% trans "This ticket cannot be resolved or closed until the tickets it depends on are resolved." %}
{% endif %} - {% ifequal ticket.status 1 %} + {% if ticket.status == 1 %}
- {% endifequal %} - {% ifequal ticket.status 2 %} + {% endif %} + {% if ticket.status == 2 %}
- {% endifequal %} - {% ifequal ticket.status 3 %} + {% endif %} + {% if ticket.status == 3 %}
- {% endifequal %} - {% ifequal ticket.status 4 %} + {% endif %} + {% if ticket.status == 4 %}
- {% endifequal %} - {% ifequal ticket.status 5 %} + {% endif %} + {% if ticket.status == 5 %}
- {% endifequal %} + {% endif %} {% if helpdesk_settings.HELPDESK_UPDATE_PUBLIC_DEFAULT %} From 5388ece5ede9685152401fc07ddf61a1a7f8a6a4 Mon Sep 17 00:00:00 2001 From: Nick McCullum Date: Fri, 1 Apr 2022 16:36:19 -0300 Subject: [PATCH 7/9] removed more deprecated functionality --- helpdesk/templates/helpdesk/debug.html | 4 ++-- helpdesk/templates/helpdesk/navigation-header.html | 2 +- helpdesk/templates/helpdesk/navigation-sidebar.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/helpdesk/templates/helpdesk/debug.html b/helpdesk/templates/helpdesk/debug.html index e182dcc2..85c19e8c 100644 --- a/helpdesk/templates/helpdesk/debug.html +++ b/helpdesk/templates/helpdesk/debug.html @@ -3,9 +3,9 @@

Queries

{{ sql_queries|length }} Quer{{ sql_queries|pluralize:"y,ies" }} - {% ifnotequal sql_queries|length 0 %} + {% if sql_queries|length != 0 %} (Show) - {% endifnotequal %} + {% endif %}

diff --git a/helpdesk/templates/helpdesk/navigation-header.html b/helpdesk/templates/helpdesk/navigation-header.html index bee20ccf..769f10da 100644 --- a/helpdesk/templates/helpdesk/navigation-header.html +++ b/helpdesk/templates/helpdesk/navigation-header.html @@ -34,7 +34,7 @@ {% for q in user_saved_queries_ %} {{ q.title }} {% if q.shared %} - (Shared{% ifnotequal user q.user %} by {{ q.user.get_username }}{% endifnotequal %}) + (Shared{% if user != q.user %} by {{ q.user.get_username }}{% endif %}) {% endif %} {% endfor %} diff --git a/helpdesk/templates/helpdesk/navigation-sidebar.html b/helpdesk/templates/helpdesk/navigation-sidebar.html index 6d2c7af1..07c062f5 100644 --- a/helpdesk/templates/helpdesk/navigation-sidebar.html +++ b/helpdesk/templates/helpdesk/navigation-sidebar.html @@ -25,7 +25,7 @@ {% for q in user_saved_queries_ %} {{ q.title }} {% if q.shared %} - (Shared{% ifnotequal user q.user %} by {{ q.user.get_username }}{% endifnotequal %}) + (Shared{% if user != q.user %} by {{ q.user.get_username }}{% endif %}) {% endif %} {% endfor %} From 91229b9292c4a07cfdd1b6f098c2bad62ffcd0d7 Mon Sep 17 00:00:00 2001 From: Nick McCullum Date: Mon, 4 Apr 2022 14:52:52 -0300 Subject: [PATCH 8/9] removed even more deprecated functionality --- helpdesk/templates/helpdesk/filters/owner.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpdesk/templates/helpdesk/filters/owner.html b/helpdesk/templates/helpdesk/filters/owner.html index 0e7b64cc..87e5bfad 100644 --- a/helpdesk/templates/helpdesk/filters/owner.html +++ b/helpdesk/templates/helpdesk/filters/owner.html @@ -14,7 +14,7 @@ {% endwith %} {% for u in user_choices %} {% endfor %} From 55c638aeef0b3032eab28bcdc8ee313da9cbf9c0 Mon Sep 17 00:00:00 2001 From: Nick McCullum Date: Mon, 4 Apr 2022 15:27:50 -0300 Subject: [PATCH 9/9] some more template improvements --- helpdesk/templates/helpdesk/ticket.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpdesk/templates/helpdesk/ticket.html b/helpdesk/templates/helpdesk/ticket.html index 54324f3b..97617785 100644 --- a/helpdesk/templates/helpdesk/ticket.html +++ b/helpdesk/templates/helpdesk/ticket.html @@ -174,10 +174,10 @@
-
+
-
+
{{ form.due_date }}