From abc5c119ffbab1b2b065b15ea8c0045a4279c455 Mon Sep 17 00:00:00 2001 From: FSMPI Admin-Team <admin@fsmpi.rwth-aachen.de> Date: Sun, 4 Jun 2017 03:05:49 +0200 Subject: [PATCH] Fix existance-check of documents on index --- models/database.py | 3 ++- templates/index.html | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/models/database.py b/models/database.py index a60440c..28ef73a 100644 --- a/models/database.py +++ b/models/database.py @@ -281,10 +281,11 @@ class Protocol(DatabaseModel): if not todo.is_done() ] - def has_compiled_document(self): + def has_compiled_document(self, private=None): candidates = [ document for document in self.documents if document.is_compiled + and (private is None or document.is_private == private) ] return len(candidates) > 0 diff --git a/templates/index.html b/templates/index.html index 03c0d2d..7db27c9 100644 --- a/templates/index.html +++ b/templates/index.html @@ -32,7 +32,7 @@ {% if protocol.protocoltype.has_modify_right(current_user()) %} <a class="btn btn-default" href="{{url_for("update_protocol", protocol_id=protocol.id)}}">Protokoll editieren</a> {% endif %} - {% if protocol.has_compiled_document() %} + {% if protocol.has_compiled_document(private=show_private) %} <a class="btn btn-success" href="{{url_for("download_document", document_id=protocol.get_compiled_document(private=show_private).id)}}">Download</a> {% endif %} </div> -- GitLab