diff --git a/sar_call_details.py b/sar_call_details.py index f4501ec..e5173a1 100644 --- a/sar_call_details.py +++ b/sar_call_details.py @@ -247,9 +247,9 @@ def delete_file(attachment_id): return redirect(url_for('sar_details', id=sar_id)) -@app.route('/download_attachment/') +@app.route('/download_file/') @login_required -def download_attachment(filename): +def download_file(filename): # Implement code to serve the attachment for download # You may use Flask's send_from_directory or send_file return send_from_directory(app.config['STORAGE_DIR'], filename) diff --git a/templates/sar_details.html b/templates/sar_details.html index e4205af..255a882 100644 --- a/templates/sar_details.html +++ b/templates/sar_details.html @@ -103,8 +103,8 @@ {% set ns.drawn = true %} {% endif %} {% endfor %} @@ -123,46 +123,38 @@ {# File attachments part #} File attachment:

{% set ns=namespace(has_file = false) %} + {% set fs=namespace(filename = 0) %} {% for file in comments_with_attachment %} {% if file.comment_id == comment.id %} {% set ns.has_file = true %} - {% if file.is_image %} - - {% set filename = file.file_name %} - {% else %} - {{ file.file_name }} - {% endif %} + + {% if file.is_image %} + + {% else %} + {{ file.file_name }} + {% endif %} + {% set fs.filename = file.id %} + {% endif %} {% endfor %} {% if is_logged_in %} {% if ns.has_file %} - - - -
- {# Download attachment #} - - - -
- {# Delete attachment #} - - -
-
+ +

+ {# Delete attachment #} + + +
{% else %}
-