diff --git a/server.py b/server.py index 2ef4e0a96eeeae2c8855fb210528fc6112088a39..b778c3da577edb07922db662586eaf9d75cb2ae0 100755 --- a/server.py +++ b/server.py @@ -148,7 +148,7 @@ def show_type(type_id): protocoltype_table = ProtocolTypeTable(protocoltype) default_tops_table = DefaultTOPsTable(protocoltype.default_tops, protocoltype) reminders_table = MeetingRemindersTable(protocoltype.reminders, protocoltype) - return render_template("type-show.html", protocoltype=protocoltype, protocoltype_table=protocoltype_table, default_tops_table=default_tops_table, reminders_table=reminders_table) + return render_template("type-show.html", protocoltype=protocoltype, protocoltype_table=protocoltype_table, default_tops_table=default_tops_table, reminders_table=reminders_table, mail_active=config.MAIL_ACTIVE) @app.route("/type/reminders/new/<int:type_id>", methods=["GET", "POST"]) @login_required @@ -455,6 +455,9 @@ def etherpull_protocol(protocol_id): if protocol is None or not protocol.protocoltype.has_modify_right(user): flash("Invalides Protokoll oder keine Berechtigung.", "alert-error") return redirect(request.args.get("next") or url_for("index")) + if not config.ETHERPAD_ACTIVE: + flash("Die Etherpadfunktion ist nicht aktiviert.", "alert-error") + return redirect(request.args.get("next") or url_for("show_protocol", protocol_id=protocol_id)) protocol.source = get_etherpad_text(protocol.get_identifier()) db.session.commit() tasks.parse_protocol(protocol) @@ -576,6 +579,9 @@ def etherpush_protocol(protocol_id): if protocol is None or not protocol.protocoltype.has_modify_right(user): flash("Invalides Protokoll oder keine Berechtigung.", "alert-error") return redirect(request.args.get("next") or url_for("index")) + if not config.ETHERPAD_ACTIVE: + flash("Die Etherpadfunktion ist nicht aktiviert.", "alert-error") + return redirect(request.args.get("next") or url_for("show_protocol", protocol_id=protocol_id)) if set_etherpad_text(protocol.get_identifier(), protocol.get_template()): flash("Vorlage von {} in Etherpad hochgeladen.".format(protocol.get_identifier()), "alert-success") else: @@ -606,6 +612,9 @@ def send_protocol(protocol_id): if protocol is None or not protocol.protocoltype.has_modify_right(user): flash("Invalides Protokoll oder keine Berechtigung.", "alert-error") return redirect(request.args.get("next") or url_for("index")) + if not config.MAIL_ACTIVE: + flash("Die Mailfunktion ist nicht aktiviert.", "alert-error") + return redirect(request.args.get("next") or url_for("show_protocol", protocol_id=protocol_id)) tasks.send_protocol(protocol) flash("Das Protokoll wurde versandt.", "alert-success") return redirect(request.args.get("next") or url_for("show_protocol", protocol_id=protocol.id)) @@ -926,6 +935,9 @@ def print_document(document_id): if document is None or not document.protocol.protocoltype.has_modify_right(user): flash("Invalides Protokoll oder keine Berechtigung.", "alert-error") return redirect(request.args.get("next") or url_for("index")) + if not config.PRINTING_ACTIVE: + flash("Die Druckfunktion ist nicht aktiviert.", "alert-error") + return redirect(request.args.get("next") or url_for("show_protocol", protocol_id=document.protocol.id)) tasks.print_file(document.get_filename(), document.protocol) flash("Das Dokument {} wird gedruckt.".format(document.name), "alert-success") return redirect(request.args.get("next") or url_for("show_protocol", protocol_id=document.protocol.id)) @@ -993,6 +1005,8 @@ def logout(): return redirect(url_for(".index")) def check_and_send_reminders(): + if not config.MAIL_ACTIVE: + return with app.app_context(): current_time = datetime.now() current_day = current_time.date() diff --git a/templates/protocol-show.html b/templates/protocol-show.html index f2aef05326560bdc24bb56ca7c21d1873cc11d54..965ed6202292144edb8c35d701ed0e38f9a52c7c 100644 --- a/templates/protocol-show.html +++ b/templates/protocol-show.html @@ -12,19 +12,30 @@ <div class="container"> <div class="btn-group"> {% if has_modify_right %} + {% if config.ETHERPAD_ACTIVE %} <a class="btn {% if protocol.source is none %}btn-primary{% else %}btn-default{% endif %}" href="{{url_for("etherpull_protocol", protocol_id=protocol.id)}}">Aus Etherpad</a> + {% endif %} {% if protocol.source is not none %} - <a class="btn btn-primary" href="{{url_for("get_protocol_source", protocol_id=protocol.id)}}">Download Quelltext</a> + <a class="btn btn-primary" href="{{url_for("get_protocol_source", protocol_id=protocol.id)}}">Quelltext</a> {% endif %} - <a class="btn {% if protocol.is_done() %}btn-success{% else %}btn-default{% endif %}" href="{{url_for("update_protocol", protocol_id=protocol.id)}}">Protokoll editieren</a> + <a class="btn {% if protocol.is_done() %}btn-success{% else %}btn-default{% endif %}" href="{{url_for("update_protocol", protocol_id=protocol.id)}}">Editieren</a> {% if not protocol.is_done() %} <a class="btn btn-default" href="{{url_for("get_protocol_template", protocol_id=protocol.id)}}">Vorlage</a> + {% if config.ETHERPAD_ACTIVE %} <a class="btn btn-primary" href="{{url_for("etherpush_protocol", protocol_id=protocol.id)}}">In Etherpad</a> + {% endif %} {% else %} - <a class="btn btn-default" href="{{url_for("send_protocol", protocol_id=protocol.id)}}">Per Mail versenden</a> + {% if config.MAIL_ACTIVE %} + <a class="btn btn-default" href="{{url_for("send_protocol", protocol_id=protocol.id)}}">Mail versenden</a> + {% endif %} {% endif %} + {% if config.ETHERPAD_ACTIVE %} <a class="btn btn-default" href="{{protocol.get_etherpad_link()}}" target="_blank">Etherpad</a> + {% endif %} <a class="btn btn-default" href="{{url_for("show_type", type_id=protocol.protocoltype.id)}}">Typ</a> + {% if protocol.has_compiled_document() %} + <a class="btn btn-success" href="{{url_for("download_document", document_id=protocol.get_compiled_document().id)}}">Download</a> + {% endif %} <a class="btn btn-danger" href="{{url_for("delete_protocol", protocol_id=protocol.id)}}" onclick="return confirm('Bist du dir sicher, dass du das Protokoll {{protocol.get_identifier()}} löschen möchtest?');">Löschen</a> {% endif %} </div> diff --git a/templates/type-show.html b/templates/type-show.html index 6ec51065422f58d61bee2c7d9199f08adbecb617..415ad188b09c60d6eba15e0de03390f147777632 100644 --- a/templates/type-show.html +++ b/templates/type-show.html @@ -7,6 +7,8 @@ {{render_single_table(protocoltype_table)}} {{render_table(default_tops_table)}} Standard-TOPs mit negativer Sortierung werden vor und die mit positiver Sortierung nach den TOPs eingefügt. - {{render_table(reminders_table)}} + {% if mail_active %} + {{render_table(reminders_table)}} + {% endif %} </div> {% endblock %} diff --git a/views/tables.py b/views/tables.py index 72c6390db3641ef6aea138f6432440cce928d307..2c09ec9ca3494f51ee7675be564fbe3e61c35bfb 100644 --- a/views/tables.py +++ b/views/tables.py @@ -3,6 +3,8 @@ from flask import Markup, url_for, request from models.database import Protocol, ProtocolType, DefaultTOP, TOP, Todo, Decision from shared import date_filter, datetime_filter, date_filter_short, current_user, check_login +import config + class Table: def __init__(self, title, values, newlink=None, newtext=None): self.title = title @@ -105,16 +107,21 @@ class ProtocolTypeTable(SingleValueTable): super().__init__(protocoltype.name, protocoltype, newlink=url_for("edit_type", type_id=protocoltype.id)) def headers(self): - headers = ["Name", "Abkürzung", "Organisation", "Beginn", - "Öffentlich", "Interne Gruppe", "Öffentliche Gruppe", - "Interner Verteiler", "Öffentlicher Verteiler", - "Drucker", "Wiki"] + general_headers = ["Name", "Abkürzung", "Organisation", "Beginn", + "Öffentlich", "Interne Gruppe", "Öffentliche Gruppe"] + mail_headers = ["Interner Verteiler", "Öffentlicher Verteiler"] + if not config.MAIL_ACTIVE: + mail_headers = [] + printing_headers = ["Drucker"] if config.PRINTING_ACTIVE else [] + wiki_headers = ["Wiki"] if self.value.use_wiki: - headers.append("Wiki-Kategorie") - return headers + wiki_headers.append("Wiki-Kategorie") + if not config.WIKI_ACTIVE: + wiki_headers = [] + return general_headers + mail_headers + printing_headers + wiki_headers def row(self): - row = [ + general_part = [ self.value.name, self.value.short_name, self.value.organization, @@ -122,14 +129,24 @@ class ProtocolTypeTable(SingleValueTable): Table.bool(self.value.is_public), self.value.private_group, self.value.public_group, + ] + mail_part = [ self.value.private_mail, self.value.public_mail, - self.value.printer, + ] + if not config.MAIL_ACTIVE: + mail_part = [] + printing_part = [self.value.printer] + if not config.PRINTING_ACTIVE: + printing_part = [] + wiki_part = [ (Table.bool(self.value.use_wiki) + ((", " + ("Öffentlich" if self.value.wiki_only_public else "Intern")) if self.value.use_wiki else "")) ] if self.value.use_wiki: - row.append(self.value.wiki_category) - return row + wiki_part.append(self.value.wiki_category) + if not config.WIKI_ACTIVE: + wiki_part = [] + return general_part + mail_part + printing_part + wiki_part class DefaultTOPsTable(Table): def __init__(self, tops, protocoltype=None): @@ -287,13 +304,13 @@ class DocumentsTable(Table): def row(self, document): user = current_user() + links = [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))] + if config.PRINTING_ACTIVE: + links.append(Table.link(url_for("print_document", document_id=document.id), "Drucken")) return [ document.id, Table.link(url_for("download_document", document_id=document.id), document.name), - Table.concat([ - 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)), - Table.link(url_for("print_document", document_id=document.id), "Drucken") - ]) - if document.protocol.protocoltype.has_modify_right(user) - else "" + Table.concat(links) + if document.protocol.protocoltype.has_modify_right(user) + else "" ]