diff --git a/server.py b/server.py index 57790e0f0cc4180841420415748d6c92ab25030e..660b78086237bb78a33eb79c6a8bfca431ea09f9 100755 --- a/server.py +++ b/server.py @@ -1506,6 +1506,17 @@ def print_decision(decisiondocument): "show_protocol", protocol_id=decisiondocument.decision.protocol.id) +@app.route("/decision/download/<int:decisiondocument_id>") +@login_required +@protect_csrf +@db_lookup(DecisionDocument) +@require_private_view_right() +def download_decision(decisiondocument): + return send_file( + decisiondocument.as_file_like(), cache_timeout=1, + as_attachment=True, attachment_filename=decisiondocument.name) + + @app.route("/errors/list") @back.anchor @login_required diff --git a/templates/protocol-show.html b/templates/protocol-show.html index 3ee28171047218c9fd897e19e3178aed751f24fe..16188fca6cdc3d82d661d4244822ef98528a9b75 100644 --- a/templates/protocol-show.html +++ b/templates/protocol-show.html @@ -103,8 +103,11 @@ {% for decision in protocol.decisions %} <li> {{decision.content}} - {% if config.PRINTING_ACTIVE and has_private_view_right and decision.document is not none %} - <a href="{{url_for("print_decision", decisiondocument_id=decision.document.id, csrf_token=get_csrf_token())}}">Drucken</a> + {% if has_private_view_right and decision.document is not none %} + {% if config.PRINTING_ACTIVE %} + <a href="{{url_for("print_decision", decisiondocument_id=decision.document.id, csrf_token=get_csrf_token())}}">Drucken</a> + {% endif %} + <a href="{{url_for("download_decision", decisiondocument_id=decision.document.id, csrf_token=get_csrf_token())}}">Download</a> {% endif %} {{render_likes(decision.likes, decision_id=decision.id)}}</h2> </li>