mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-21 23:43:11 +01:00
Do not show attachments in public tickets if not enabled, fix attachment upload if enabled
Attachments in followups were still shown (if they existed) even if HELPDESK_ENABLE_ATTACHMENT was set to False. If attachments were enabled it was not possible to upload them because the JavaScript code for uploading attachments to public was not loaded in the template.
This commit is contained in:
parent
78cf89ca9b
commit
20cd08fe28
@ -9,6 +9,7 @@
|
||||
|
||||
{% include 'helpdesk/base-head.html' %}
|
||||
{% block helpdesk_head %}{% endblock %}
|
||||
{% include 'helpdesk/base_js.html' %}
|
||||
|
||||
</head>
|
||||
|
||||
|
@ -81,10 +81,13 @@
|
||||
<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>
|
||||
{% endfor %}
|
||||
</ul></div>{% endif %}
|
||||
|
||||
{% if helpdesk_settings.HELPDESK_ENABLE_ATTACHMENTS %}
|
||||
{% for attachment in followup.followupattachment_set.all %}{% if forloop.first %}<div class='attachments'><ul>{% endif %}
|
||||
<li><a href='{{ attachment.file.url }}'>{{ attachment.filename }}</a> ({{ attachment.mime_type }}, {{ attachment.size|filesizeformat }})</li>
|
||||
{% if forloop.last %}</ul></div>{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@ -133,6 +136,7 @@
|
||||
<dt><label for='id_file'>{% trans "Attach a File" %}</label></dt>
|
||||
<dd>
|
||||
<div class="add_file_fields_wrap">
|
||||
<button class="add_file_field_button btn btn-success btn-xs">{% trans "Add Another File" %}</button>
|
||||
<div><label class='btn btn-primary btn-sm btn-file'>
|
||||
Browse... <input type="file" name='attachment' id='file0' style='display: none;'/>
|
||||
</label><span> </span><span id='selectedfilename0'>{% trans 'No files selected.' %}</span></div>
|
||||
@ -146,7 +150,47 @@
|
||||
|
||||
<button class="btn btn-primary btn-lg" style="margin-bottom:10px" type='submit'>{% trans "Update This Ticket" %}</button>
|
||||
|
||||
{% csrf_token %}</form>
|
||||
{% csrf_token %}
|
||||
</form>
|
||||
|
||||
{% if helpdesk_settings.HELPDESK_ENABLE_ATTACHMENTS %}
|
||||
<script type='text/javascript' language='javascript'>
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#ShowFileUpload").click(function() {
|
||||
$("#FileUpload").fadeIn();
|
||||
$("#ShowFileUploadPara").hide();
|
||||
});
|
||||
|
||||
// lists for file input change events, then updates the associated text label
|
||||
// with the file name selected
|
||||
$('.add_file_fields_wrap').on('fileselect', ':file', function(event, numFiles, label, browseButtonNum) {
|
||||
$("#selectedfilename"+browseButtonNum).html(label);
|
||||
});
|
||||
|
||||
var x = 0;
|
||||
var wrapper = $(".add_file_fields_wrap"); //Fields wrapper
|
||||
var add_button = $(".add_file_field_button"); //Add button ID
|
||||
|
||||
$(add_button).click(function(e){ //on add input button click
|
||||
x++;
|
||||
e.preventDefault();
|
||||
$(wrapper).append("<div><label class='btn btn-primary btn-sm btn-file'>Browse... <input type='file' name='attachment' id='file" + x + "' multiple style='display: none;'/></label><span> </span><span id='selectedfilename" + x + "'>{% trans 'No files selected.' %}</span></div>"); //add input box
|
||||
});
|
||||
});
|
||||
|
||||
// this function listens for changes on any file input, and
|
||||
// emits the appropriate event to update the input's text.
|
||||
// Needed to have properly styled file input buttons! (this really shouldn't be this hard...)
|
||||
$(document).on('change', ':file', function() {
|
||||
var input = $(this),
|
||||
inputWidgetNum = $(this).attr('id').split("file")[1],
|
||||
numFiles = input.get(0).files ? input.get(0).files.length : 1,
|
||||
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
|
||||
input.trigger('fileselect', [numFiles, label, inputWidgetNum]);
|
||||
});
|
||||
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user