Add HELPDESK_ENABLE_ATTACHMENTS setting and make it show/hide attachment related UI

Default setting is false. This is not backward compatible.
The rationale is: attachments contain most likely sensitive information.
By default they are served without access control.  Currently there is
no simple feature to configure access control.  To avoid unintentional
disclosure attachments should be an opt in: you have been warned.
This commit is contained in:
Georg Lehner
2024-06-06 15:47:50 +02:00
parent c77bb30035
commit dd4c04945a
5 changed files with 37 additions and 24 deletions

View File

@ -239,17 +239,18 @@ class AbstractTicketForm(CustomFieldMixin, forms.Form):
label=_('Due on'),
)
attachment = forms.FileField(
widget=forms.FileInput(attrs={'class': 'form-control-file'}),
required=False,
label=_('Attach File'),
help_text=_('You can attach a file to this ticket. '
'Only file types such as plain text (.txt), '
'a document (.pdf, .docx, or .odt), '
'or screenshot (.png or .jpg) may be uploaded.'),
validators=[validate_file_extension]
)
if helpdesk_settings.HELPDESK_ENABLE_ATTACHMENTS:
attachment = forms.FileField(
widget=forms.FileInput(attrs={'class': 'form-control-file'}),
required=False,
label=_('Attach File'),
help_text=_('You can attach a file to this ticket. '
'Only file types such as plain text (.txt), '
'a document (.pdf, .docx, or .odt), '
'or screenshot (.png or .jpg) may be uploaded.'),
validators=[validate_file_extension]
)
class Media:
js = ('helpdesk/js/init_due_date.js',
'helpdesk/js/init_datetime_classes.js')