diff --git a/server.py b/server.py index 0e938e02aaefbf0382c4a058a19a49dbd98853e5..dad68a4aa30912180ef4935adb013980e00dc7de 100755 --- a/server.py +++ b/server.py @@ -487,7 +487,7 @@ def show_protocol(protocol): if (not document.is_private and document.protocol.has_public_view_right(user)) or (document.is_private and document.protocol.protocoltype.has_private_view_right(user)) ] - documents_table = DocumentsTable(visible_documents) + documents_table = DocumentsTable(visible_documents, protocol) document_upload_form = DocumentUploadForm() source_upload_form = KnownProtocolSourceUploadForm() time_diff = protocol.date - datetime.now().date() diff --git a/views/forms.py b/views/forms.py index 94f5dfa583fb02e9c3322fab12a364a56a66564c..d41397ccb2873e374666e4e8f9fd0beec8fcd9ee 100644 --- a/views/forms.py +++ b/views/forms.py @@ -153,7 +153,7 @@ class NewProtocolForm(FlaskForm): class DocumentUploadForm(FlaskForm): document = FileField("Datei") - private = BooleanField("Intern") + is_private = BooleanField("Intern") class KnownProtocolSourceUploadForm(FlaskForm): source = FileField("Quellcode") diff --git a/views/tables.py b/views/tables.py index 7318137991a5842439e61fd4f215ccea1ccc5a29..4d98c4c2ea9a4707b552fa912221fd08553db5d7 100644 --- a/views/tables.py +++ b/views/tables.py @@ -62,16 +62,13 @@ class ProtocolsTable(Table): result = ["ID", "Sitzung", "Sitzung", "Datum"] state_part = ["Status"] search_part = ["Suchergebnis"] - login_part = ["Typ"] - admin_part = ["Löschen"] + login_part = ["Typ", ""] if self.search_results is None: result.extend(state_part) else: result.extend(search_part) if check_login(): result.extend(login_part) - if protocol.protocoltype.has_admin_right(user): - result.extend(admin_part) return result def classes(self): @@ -101,6 +98,8 @@ class ProtocolsTable(Table): result.append(Table.link(url_for("show_type", protocoltype_id=protocol.protocoltype.id), protocol.protocoltype.short_name)) if protocol.protocoltype.has_admin_right(user): result.append(Table.link(url_for("delete_protocol", protocol_id=protocol.id), "Löschen", confirm="Bist du dir sicher, dass du das Protokoll {} löschen möchtest?".format(protocol.get_identifier()))) + else: + result.append("") else: result.extend(["", ""]) return result @@ -410,14 +409,27 @@ class DecisionsTable(Table): return content_part + category_part + action_part class DocumentsTable(Table): - def __init__(self, documents): + def __init__(self, documents, protocol): super().__init__("Anhang", documents) + self.protocol = protocol def headers(self): - return ["ID", "Name", ""] + user = current_user() + general_headers = ["ID", "Name"] + visibility_headers = [] + if self.protocol.has_private_view_right(user): + visibility_headers = ["Sichtbarkeit"] + action_headers=[""] + return general_headers + visibility_headers + action_headers def classes(self): - return [None, None, "hidden-xs"] + user = current_user() + general_part = [None, None] + visibility_part = [] + if self.protocol.has_private_view_right(user): + visibility_part = [None] + action_part = ["hidden-xs"] + return general_part + visibility_part + action_part def row(self, document): user = current_user() @@ -426,11 +438,15 @@ class DocumentsTable(Table): links.append(Table.link(url_for("print_document", document_id=document.id), "Drucken")) if document.protocol.protocoltype.has_admin_right(user): links.append(Table.link(url_for("delete_document", document_id=document.id), "Löschen", confirm="Bist du dir sicher, dass du das Dokument {} löschen willst?".format(document.name))) - return [ + general_part = [ document.id, Table.link(url_for("download_document", document_id=document.id), document.name), - Table.concat(links) ] + visibility_part = [] + if document.protocol.has_private_view_right(user): + visibility_part = ["Intern" if document.is_private else "Öffentlich"] + action_part = [Table.concat(links)] + return general_part + visibility_part + action_part class TodoMailsTable(Table): def __init__(self, todomails):