From 345a713777d7a7c559610f72db1ae22d6187f985 Mon Sep 17 00:00:00 2001 From: Thomas Wheeler Date: Fri, 31 Dec 2021 14:59:37 -0800 Subject: [PATCH 01/22] updated validate_file_extension() to look for defined VALID_EXTENTIONS in settings.py so its configurable --- helpdesk/validators.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/helpdesk/validators.py b/helpdesk/validators.py index ced10523..602917d5 100644 --- a/helpdesk/validators.py +++ b/helpdesk/validators.py @@ -2,14 +2,22 @@ # # validators for file uploads, etc. - +from django.conf import settings def validate_file_extension(value): import os from django.core.exceptions import ValidationError ext = os.path.splitext(value.name)[1] # [0] returns path+filename - valid_extensions = ['.txt', '.pdf', '.doc', '.docx', '.odt', '.jpg', '.png'] # TODO: we might improve this with more thorough checks of file types # rather than just the extensions. - if not ext.lower() in valid_extensions: + + # check if VALID_EXTENSTIONS is defined in settings.py + # if not use defaults + + if settings.VALID_EXTENSTIONS: + valid_extenstions = settings.VALID_EXTENSTIONS + else: + valid_extenstions = ['.txt', '.pdf', '.doc', '.docx', '.odt', '.jpg', '.png'] + + if not ext.lower() in valid_extenstions: raise ValidationError('Unsupported file extension.') From ae73fec2a0a5a024028d218db00e9cdb488c2a5e Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Fri, 31 Dec 2021 22:21:28 -0500 Subject: [PATCH 02/22] Spellchecking in validators.py --- helpdesk/validators.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/helpdesk/validators.py b/helpdesk/validators.py index 602917d5..01500a9a 100644 --- a/helpdesk/validators.py +++ b/helpdesk/validators.py @@ -4,6 +4,8 @@ from django.conf import settings +#TODO: can we use the builtin Django validator instead? +# see: https://docs.djangoproject.com/en/4.0/ref/validators/#fileextensionvalidator def validate_file_extension(value): import os from django.core.exceptions import ValidationError @@ -11,13 +13,13 @@ def validate_file_extension(value): # TODO: we might improve this with more thorough checks of file types # rather than just the extensions. - # check if VALID_EXTENSTIONS is defined in settings.py + # check if VALID_EXTENSIONS is defined in settings.py # if not use defaults - if settings.VALID_EXTENSTIONS: - valid_extenstions = settings.VALID_EXTENSTIONS + if settings.VALID_EXTENSIONS: + valid_extensions = settings.VALID_EXTENSIONS else: - valid_extenstions = ['.txt', '.pdf', '.doc', '.docx', '.odt', '.jpg', '.png'] + valid_extensions = ['.txt', '.pdf', '.doc', '.docx', '.odt', '.jpg', '.png'] - if not ext.lower() in valid_extenstions: + if not ext.lower() in valid_extensions: raise ValidationError('Unsupported file extension.') From 3695cfa19dd860ab1b6f38486b5d1ff0ade3c52f Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Tue, 4 Jan 2022 11:47:31 -0500 Subject: [PATCH 03/22] Remove comma in staff.py to address #988 --- helpdesk/views/staff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 3b3b9a65..6b2751b5 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -851,7 +851,7 @@ def mass_update(request): 'ticket_cc': ('closed_cc', context), } if t.assigned_to and t.assigned_to.usersettings_helpdesk.email_on_ticket_change: - roles['assigned_to'] = ('closed_owner', context), + roles['assigned_to'] = ('closed_owner', context) messages_sent_to.update(t.send( roles, From 7ac8d20cbefcaae9e627fde65897161fada0c6c7 Mon Sep 17 00:00:00 2001 From: Jon Renaut Date: Wed, 26 Jan 2022 14:26:52 -0500 Subject: [PATCH 04/22] Fix Javascript typo This fix enables uploading new attachments to an existing ticket --- helpdesk/templates/helpdesk/ticket.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpdesk/templates/helpdesk/ticket.html b/helpdesk/templates/helpdesk/ticket.html index caf4bb3d..1af663f9 100644 --- a/helpdesk/templates/helpdesk/ticket.html +++ b/helpdesk/templates/helpdesk/ticket.html @@ -239,7 +239,7 @@ $(document).ready(function() { $('#id_preset').change(function() { preset = $('#id_preset').val(); if (preset != '') { - $.get("{% url 'helpdesk:raw' "preset" %}?id=" + preset, function(data) { + $.get("{% url 'helpdesk:raw' " + preset + " %}?id=" + preset, function(data) { $("#commentBox").val(data) }); } From a2782c07f46c9e241fd1ca9fefd1c47e8523ed5b Mon Sep 17 00:00:00 2001 From: Benbb96 Date: Thu, 27 Jan 2022 09:51:00 +0100 Subject: [PATCH 05/22] Show active page in sidebar depending on the request path url --- .../templates/helpdesk/navigation-sidebar.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/helpdesk/templates/helpdesk/navigation-sidebar.html b/helpdesk/templates/helpdesk/navigation-sidebar.html index b213eaf7..6d2c7af1 100644 --- a/helpdesk/templates/helpdesk/navigation-sidebar.html +++ b/helpdesk/templates/helpdesk/navigation-sidebar.html @@ -3,13 +3,13 @@