From f31f3eb2336d688bc907e6abf92ae09373ec7c5c Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:04:54 +0000 Subject: [PATCH] Filter custom fields according to settings list --- helpdesk/forms.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 7b2dd459..0ce76c08 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -33,7 +33,8 @@ from helpdesk.settings import ( CUSTOMFIELD_DATE_FORMAT, CUSTOMFIELD_DATETIME_FORMAT, CUSTOMFIELD_TIME_FORMAT, - CUSTOMFIELD_TO_FIELD_DICT + CUSTOMFIELD_TO_FIELD_DICT, + HELPDESK_SHOW_CUSTOM_FIELDS_FOLLOW_UP_LIST, ) from helpdesk.validators import validate_file_extension from helpdesk.signals import new_ticket_done @@ -191,7 +192,11 @@ class EditTicketCustomFieldForm(EditTicketForm): """ super(EditTicketCustomFieldForm, self).__init__(*args, **kwargs) - del self.fields['merged_to'] + if HELPDESK_SHOW_CUSTOM_FIELDS_FOLLOW_UP_LIST: + fields = list(self.fields) + for field in fields: + if field != 'id' and field.replace("custom_", "", 1) not in HELPDESK_SHOW_CUSTOM_FIELDS_FOLLOW_UP_LIST: + self.fields.pop(field, None) def save(self, *args, **kwargs):