mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-12 09:50:45 +01:00
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:
parent
c77bb30035
commit
dd4c04945a
@ -239,17 +239,18 @@ class AbstractTicketForm(CustomFieldMixin, forms.Form):
|
|||||||
label=_('Due on'),
|
label=_('Due on'),
|
||||||
)
|
)
|
||||||
|
|
||||||
attachment = forms.FileField(
|
if helpdesk_settings.HELPDESK_ENABLE_ATTACHMENTS:
|
||||||
widget=forms.FileInput(attrs={'class': 'form-control-file'}),
|
attachment = forms.FileField(
|
||||||
required=False,
|
widget=forms.FileInput(attrs={'class': 'form-control-file'}),
|
||||||
label=_('Attach File'),
|
required=False,
|
||||||
help_text=_('You can attach a file to this ticket. '
|
label=_('Attach File'),
|
||||||
'Only file types such as plain text (.txt), '
|
help_text=_('You can attach a file to this ticket. '
|
||||||
'a document (.pdf, .docx, or .odt), '
|
'Only file types such as plain text (.txt), '
|
||||||
'or screenshot (.png or .jpg) may be uploaded.'),
|
'a document (.pdf, .docx, or .odt), '
|
||||||
validators=[validate_file_extension]
|
'or screenshot (.png or .jpg) may be uploaded.'),
|
||||||
)
|
validators=[validate_file_extension]
|
||||||
|
)
|
||||||
|
|
||||||
class Media:
|
class Media:
|
||||||
js = ('helpdesk/js/init_due_date.js',
|
js = ('helpdesk/js/init_due_date.js',
|
||||||
'helpdesk/js/init_datetime_classes.js')
|
'helpdesk/js/init_datetime_classes.js')
|
||||||
|
@ -56,6 +56,11 @@ HELPDESK_STAFF_VIEW_PROTECTOR = getattr(settings,
|
|||||||
'HELPDESK_STAFF_VIEW_PROTECTOR',
|
'HELPDESK_STAFF_VIEW_PROTECTOR',
|
||||||
lambda _: None)
|
lambda _: None)
|
||||||
|
|
||||||
|
# Enable ticket and Email attachments
|
||||||
|
HELPDESK_ENABLE_ATTACHMENTS = getattr(settings,
|
||||||
|
'HELPDESK_ENABLE_ATTACHMENTS',
|
||||||
|
False)
|
||||||
|
|
||||||
# Enable the Dependencies field on ticket view
|
# Enable the Dependencies field on ticket view
|
||||||
HELPDESK_ENABLE_DEPENDENCIES_ON_TICKET = getattr(settings,
|
HELPDESK_ENABLE_DEPENDENCIES_ON_TICKET = getattr(settings,
|
||||||
'HELPDESK_ENABLE_DEPENDENCIES_ON_TICKET',
|
'HELPDESK_ENABLE_DEPENDENCIES_ON_TICKET',
|
||||||
|
@ -122,7 +122,8 @@
|
|||||||
<input type='hidden' name='public' value='1'>
|
<input type='hidden' name='public' value='1'>
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
{% if helpdesk_settings.HELPDESK_ENABLE_ATTACHMENTS %}
|
||||||
<p id='ShowFileUploadPara'><button class="btn btn-warning btn-sm"
|
<p id='ShowFileUploadPara'><button class="btn btn-warning btn-sm"
|
||||||
id='ShowFileUpload' onclick="$('#FileUpload')[0].style.display='block';return false;" >{% trans "Attach File(s) »" %}</button></p>
|
id='ShowFileUpload' onclick="$('#FileUpload')[0].style.display='block';return false;" >{% trans "Attach File(s) »" %}</button></p>
|
||||||
|
|
||||||
@ -140,7 +141,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<button class="btn btn-primary btn-lg" style="margin-bottom:10px" type='submit'>{% trans "Update This Ticket" %}</button>
|
<button class="btn btn-primary btn-lg" style="margin-bottom:10px" type='submit'>{% trans "Update This Ticket" %}</button>
|
||||||
|
@ -54,14 +54,16 @@
|
|||||||
<li>{% blocktrans with change.field as field and change.old_value as old_value and change.new_value as new_value %}Changed {{ field }} from {{ old_value }} to {{ new_value }}.{% endblocktrans %}</li>
|
<li>{% blocktrans with change.field as field and change.old_value as old_value and change.new_value as new_value %}Changed {{ field }} from {{ old_value }} to {{ new_value }}.{% endblocktrans %}</li>
|
||||||
{% if forloop.last %}</ul></div>{% endif %}
|
{% if forloop.last %}</ul></div>{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for attachment in followup.followupattachment_set.all %}{% if forloop.first %}{% trans "Attachments" %}:<div class='attachments'><ul>{% endif %}
|
{% if helpdesk_settings.HELPDESK_ENABLE_ATTACHMENTS %}
|
||||||
|
{% for attachment in followup.followupattachment_set.all %}{% if forloop.first %}{% trans "Attachments" %}:<div class='attachments'><ul>{% endif %}
|
||||||
<li><a href='{{ attachment.file.url }}'>{{ attachment.filename }}</a> ({{ attachment.mime_type }}, {{ attachment.size|filesizeformat }})
|
<li><a href='{{ attachment.file.url }}'>{{ attachment.filename }}</a> ({{ attachment.mime_type }}, {{ attachment.size|filesizeformat }})
|
||||||
{% if followup.user and request.user == followup.user %}
|
{% if followup.user and request.user == followup.user %}
|
||||||
<a href='{% url 'helpdesk:attachment_del' ticket.id attachment.id %}'><button class="btn btn-danger btn-sm"><i class="fas fa-trash"></i></button></a>
|
<a href='{% url 'helpdesk:attachment_del' ticket.id attachment.id %}'><button class="btn btn-danger btn-sm"><i class="fas fa-trash"></i></button></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% if forloop.last %}</ul></div>{% endif %}
|
{% if forloop.last %}</ul></div>{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
<!--- ugly long test to suppress the following if it will be empty, to save vertical space -->
|
<!--- ugly long test to suppress the following if it will be empty, to save vertical space -->
|
||||||
{% with possible=helpdesk_settings.HELPDESK_SHOW_EDIT_BUTTON_FOLLOW_UP %}
|
{% with possible=helpdesk_settings.HELPDESK_SHOW_EDIT_BUTTON_FOLLOW_UP %}
|
||||||
@ -105,10 +107,10 @@
|
|||||||
|
|
||||||
<dt><label for='commentBox'>{% trans "Comment / Resolution" %}</label></dt>
|
<dt><label for='commentBox'>{% trans "Comment / Resolution" %}</label></dt>
|
||||||
<dd><textarea rows='8' cols='70' name='comment' id='commentBox'></textarea></dd>
|
<dd><textarea rows='8' cols='70' name='comment' id='commentBox'></textarea></dd>
|
||||||
{% url "helpdesk:help_context" as context_help_url %}
|
{% url "helpdesk:help_context" as context_help_url %}
|
||||||
{% blocktrans %}
|
{% blocktrans %}
|
||||||
<dd class='form_help_text'>You can insert ticket and queue details in your message. For more information, see the <a href='{{ context_help_url }}'>context help page</a>.</dd>
|
<dd class='form_help_text'>You can insert ticket and queue details in your message. For more information, see the <a href='{{ context_help_url }}'>context help page</a>.</dd>
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
|
|
||||||
<dt><label>{% trans "New Status" %}</label></dt>
|
<dt><label>{% trans "New Status" %}</label></dt>
|
||||||
{% if not ticket.can_be_resolved %}<dd>{% trans "This ticket cannot be resolved or closed until the tickets it depends on are resolved." %}</dd>{% endif %}
|
{% if not ticket.can_be_resolved %}<dd>{% trans "This ticket cannot be resolved or closed until the tickets it depends on are resolved." %}</dd>{% endif %}
|
||||||
@ -197,7 +199,9 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if helpdesk_settings.HELPDESK_ENABLE_ATTACHMENTS %}
|
||||||
<p id='ShowFileUploadPara'><button type="button" class="btn btn-warning btn-sm" id='ShowFileUpload'>{% trans "Attach File(s) »" %}</button></p>
|
<p id='ShowFileUploadPara'><button type="button" class="btn btn-warning btn-sm" id='ShowFileUpload'>{% trans "Attach File(s) »" %}</button></p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div id='FileUpload' style='display: none;'>
|
<div id='FileUpload' style='display: none;'>
|
||||||
|
|
||||||
@ -257,7 +261,7 @@
|
|||||||
{% block helpdesk_js %}
|
{% block helpdesk_js %}
|
||||||
<script type='text/javascript' language='javascript'>
|
<script type='text/javascript' language='javascript'>
|
||||||
$( function() {
|
$( function() {
|
||||||
$( "#id_due_date" ).datepicker({dateFormat: 'yy-mm-dd'});
|
$( "#id_due_date" ).datepicker({dateFormat: 'yy-mm-dd'});
|
||||||
} );
|
} );
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -149,7 +149,8 @@
|
|||||||
<th class="table-active">{% trans "Knowlegebase item" %}</th>
|
<th class="table-active">{% trans "Knowlegebase item" %}</th>
|
||||||
<td> <a href ="{{ticket.kbitem.query_url}}"> {{ticket.kbitem}} </a> </td>
|
<td> <a href ="{{ticket.kbitem.query_url}}"> {{ticket.kbitem}} </a> </td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if helpdesk_settings.HELPDESK_ENABLE_ATTACHMENTS %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="table-active">{% trans "Attachments" %}</th>
|
<th class="table-active">{% trans "Attachments" %}</th>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
@ -171,6 +172,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="table-active">{% trans "Checklists" %}</th>
|
<th class="table-active">{% trans "Checklists" %}</th>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
|
Loading…
Reference in New Issue
Block a user