diff --git a/models/database.py b/models/database.py index c329bbec2eb1e398877a56350eb04800e29a0c22..d577ffe36a4f59065338eb63643b8acd469c95a6 100644 --- a/models/database.py +++ b/models/database.py @@ -22,7 +22,6 @@ class DatabaseModel(db.Model): __abstract__ = True def has_public_view_right(self, user): - print("DBModel") return self.get_parent().has_public_view_right(user) def has_private_view_right(self, user): @@ -105,14 +104,14 @@ class ProtocolType(DatabaseModel): return None return candidates[0] - def has_public_view_right(self, user): - return (self.has_public_anonymous_view_right() + def has_public_view_right(self, user, check_networks=True): + return (self.has_public_anonymous_view_right(check_networks=check_networks) or (user is not None and self.has_public_authenticated_view_right(user)) or self.has_admin_right(user)) - def has_public_anonymous_view_right(self): + def has_public_anonymous_view_right(self, check_networks=True): return (self.is_public - and (not self.restrict_networks + and ((not self.restrict_networks or not check_networks) or check_ip_in_networks(self.allowed_networks))) def has_public_authenticated_view_right(self, user): diff --git a/server.py b/server.py index 3a0a924dd5edcd6b56a8c6765fd14f3409a1fc4b..bb4c04e4e1c360fa13ce2c3472573134319dc11c 100755 --- a/server.py +++ b/server.py @@ -136,14 +136,15 @@ def index(): user = current_user() protocols = [ protocol for protocol in Protocol.query.all() - if protocol.protocoltype.has_public_view_right(user) + if protocol.protocoltype.has_public_view_right(user, + check_networks=False) ] def _protocol_sort_key(protocol): if protocol.date is not None: return protocol.date return datetime.now().date() current_day = datetime.now().date() - open_protocols = sorted( + all_open_protocols = sorted( [ protocol for protocol in protocols if not protocol.done @@ -151,12 +152,17 @@ def index(): ], key=_protocol_sort_key ) + open_protocols = [ + protocol for protocol in all_open_protocols + if protocol.protocoltype.has_public_view_right(user) + ] finished_protocols = sorted( [ protocol for protocol in protocols if protocol.done and (protocol.has_public_view_right(user) or protocol.has_private_view_right(user)) + and protocol.protocoltype.has_public_view_right(user) ], key=_protocol_sort_key, reverse=True @@ -174,7 +180,7 @@ def index(): return protocol.date if protocol.date is not None else datetime.now().date() todos = sorted(todos, key=_todo_sort_key, reverse=True) todos_table = TodosTable(todos) if todos is not None else None - return render_template("index.html", open_protocols=open_protocols, protocol=protocol, todos=todos, todos_table=todos_table) + return render_template("index.html", open_protocols=open_protocols, protocol=protocol, todos=todos, todos_table=todos_table, all_open_protocols=all_open_protocols) @app.route("/documentation") @login_required diff --git a/templates/index.html b/templates/index.html index f18560586a2f12d77de75b3a91ac86a2200157aa..c7a1db722bcfb18ecf956c2ccf7c0b02ee41de03 100644 --- a/templates/index.html +++ b/templates/index.html @@ -18,7 +18,11 @@ <li><a href="{{url_for("show_protocol", protocol_id=protocol.id)}}">{{protocol.protocoltype.name}}</a> am {{protocol.date|datify}}</li> {% endfor %} {% else %} - <li>Keine anstehenden Sitzungen</li> + {% if all_open_protocols|length == 0 %} + <li>Keine anstehenden Sitzungen</li> + {% else %} + <li>Die Sitzungen sind nur aus einem eingeschränkten Teil des Internets, nicht weltweit sichtbar.</li> + {% endif %} {% endif %} </ul> {% if check_login() %}