Commit c8565428 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Merge branch 'master' of git.fsmpi.rwth-aachen.de:protokollsystem/proto3

parents 0773e758 57b4ae79
...@@ -115,10 +115,10 @@ class ProtocolType(DatabaseModel): ...@@ -115,10 +115,10 @@ class ProtocolType(DatabaseModel):
] ]
@staticmethod @staticmethod
def get_public_protocoltypes(user): def get_public_protocoltypes(user, check_networks=True):
return [ return [
protocoltype for protocoltype in ProtocolType.query.all() protocoltype for protocoltype in ProtocolType.query.all()
if protocoltype.has_public_view_right(user) if protocoltype.has_public_view_right(user, check_networks=check_networks)
] ]
@staticmethod @staticmethod
......
...@@ -174,7 +174,7 @@ def index(): ...@@ -174,7 +174,7 @@ def index():
] ]
def _todo_sort_key(todo): def _todo_sort_key(todo):
protocol = todo.get_first_protocol() protocol = todo.get_first_protocol()
return protocol.date if protocol.date is not None else datetime.now().date() return protocol.date if protocol is not None and protocol.date is not None else datetime.now().date()
todos = sorted(todos, key=_todo_sort_key, reverse=True) todos = sorted(todos, key=_todo_sort_key, reverse=True)
todos_table = TodosTable(todos) if todos is not None else None todos_table = TodosTable(todos) if todos is not None else None
return render_template("index.html", open_protocols=open_protocols, protocol=protocol, todos=todos) return render_template("index.html", open_protocols=open_protocols, protocol=protocol, todos=todos)
...@@ -357,7 +357,7 @@ def list_protocols(): ...@@ -357,7 +357,7 @@ def list_protocols():
except (ValueError, TypeError): except (ValueError, TypeError):
pass pass
search_term = request.args.get("search") search_term = request.args.get("search")
protocoltypes = ProtocolType.get_public_protocoltypes(user) protocoltypes = ProtocolType.get_public_protocoltypes(user, check_networks=False)
search_form = ProtocolSearchForm(protocoltypes) search_form = ProtocolSearchForm(protocoltypes)
if protocoltype_id is not None: if protocoltype_id is not None:
search_form.protocoltype_id.data = protocoltype_id search_form.protocoltype_id.data = protocoltype_id
...@@ -489,7 +489,7 @@ def show_protocol(protocol): ...@@ -489,7 +489,7 @@ def show_protocol(protocol):
if (not document.is_private and document.protocol.has_public_view_right(user)) 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)) 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() document_upload_form = DocumentUploadForm()
source_upload_form = KnownProtocolSourceUploadForm() source_upload_form = KnownProtocolSourceUploadForm()
time_diff = protocol.date - datetime.now().date() time_diff = protocol.date - datetime.now().date()
...@@ -963,7 +963,7 @@ def list_decisions(): ...@@ -963,7 +963,7 @@ def list_decisions():
except (ValueError, TypeError): except (ValueError, TypeError):
pass pass
search_term = request.args.get("search") search_term = request.args.get("search")
protocoltypes = ProtocolType.get_public_protocoltypes(user) protocoltypes = ProtocolType.get_public_protocoltypes(user, check_networks=False)
decisioncategories = [ decisioncategories = [
category category
for protocoltype in protocoltypes for protocoltype in protocoltypes
......
...@@ -153,7 +153,7 @@ class NewProtocolForm(FlaskForm): ...@@ -153,7 +153,7 @@ class NewProtocolForm(FlaskForm):
class DocumentUploadForm(FlaskForm): class DocumentUploadForm(FlaskForm):
document = FileField("Datei") document = FileField("Datei")
private = BooleanField("Intern") is_private = BooleanField("Intern")
class KnownProtocolSourceUploadForm(FlaskForm): class KnownProtocolSourceUploadForm(FlaskForm):
source = FileField("Quellcode") source = FileField("Quellcode")
......
...@@ -58,10 +58,11 @@ class ProtocolsTable(Table): ...@@ -58,10 +58,11 @@ class ProtocolsTable(Table):
self.search_results = search_results self.search_results = search_results
def headers(self): def headers(self):
user = current_user()
result = ["ID", "Sitzung", "Sitzung", "Datum"] result = ["ID", "Sitzung", "Sitzung", "Datum"]
state_part = ["Status"] state_part = ["Status"]
search_part = ["Suchergebnis"] search_part = ["Suchergebnis"]
login_part = ["Typ", "Löschen"] login_part = ["Typ", ""]
if self.search_results is None: if self.search_results is None:
result.extend(state_part) result.extend(state_part)
else: else:
...@@ -97,6 +98,8 @@ class ProtocolsTable(Table): ...@@ -97,6 +98,8 @@ class ProtocolsTable(Table):
result.append(Table.link(url_for("show_type", protocoltype_id=protocol.protocoltype.id), protocol.protocoltype.short_name)) result.append(Table.link(url_for("show_type", protocoltype_id=protocol.protocoltype.id), protocol.protocoltype.short_name))
if protocol.protocoltype.has_admin_right(user): 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()))) 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: else:
result.extend(["", ""]) result.extend(["", ""])
return result return result
...@@ -210,10 +213,11 @@ class ProtocolTypeTable(SingleValueTable): ...@@ -210,10 +213,11 @@ class ProtocolTypeTable(SingleValueTable):
calendar_part = [self.value.calendar if self.value.calendar is not None else ""] calendar_part = [self.value.calendar if self.value.calendar is not None else ""]
if not config.CALENDAR_ACTIVE: if not config.CALENDAR_ACTIVE:
calendar_part = [] calendar_part = []
network_part = [ network_part = [Table.bool(self.value.restrict_networks)]
Table.bool(self.value.restrict_networks), if self.value.allowed_networks is not None:
", ".join(map(str.strip, self.value.allowed_networks.split(","))) network_part.append(", ".join(map(str.strip, self.value.allowed_networks.split(","))))
] else:
network_part.append("")
action_part = [Table.link(url_for("delete_type", protocoltype_id=self.value.id), "Löschen", confirm="Bist du dir sicher, dass du den Protokolltype {} löschen möchtest?".format(self.value.name))] action_part = [Table.link(url_for("delete_type", protocoltype_id=self.value.id), "Löschen", confirm="Bist du dir sicher, dass du den Protokolltype {} löschen möchtest?".format(self.value.name))]
if not self.value.has_admin_right(user): if not self.value.has_admin_right(user):
action_part = [""] action_part = [""]
...@@ -318,12 +322,12 @@ class TodosTable(Table): ...@@ -318,12 +322,12 @@ class TodosTable(Table):
def row(self, todo): def row(self, todo):
user = current_user() user = current_user()
protocol = todo.get_first_protocol() protocol = todo.get_first_protocol()
mobile_parts = [Table.link(url_for("show_todo", todo_id=todo.id), todo.get_state())]
if protocol is not None:
mobile_parts.append(Table.link(url_for("show_protocol", protocol_id=protocol.id), todo.protocoltype.short_name))
mobile_parts.append(todo.who)
row = [ row = [
Markup("<br>").join([ Markup("<br>").join(mobile_parts),
Table.link(url_for("show_todo", todo_id=todo.id), todo.get_state()),
Table.link(url_for("show_protocol", protocol_id=protocol.id), todo.protocoltype.short_name),
todo.who
]),
Table.link(url_for("show_todo", todo_id=todo.id), todo.get_id()), Table.link(url_for("show_todo", todo_id=todo.id), todo.get_id()),
todo.get_state(), todo.get_state(),
Table.link(url_for("show_protocol", protocol_id=protocol.id), protocol.get_identifier()) Table.link(url_for("show_protocol", protocol_id=protocol.id), protocol.get_identifier())
...@@ -405,14 +409,27 @@ class DecisionsTable(Table): ...@@ -405,14 +409,27 @@ class DecisionsTable(Table):
return content_part + category_part + action_part return content_part + category_part + action_part
class DocumentsTable(Table): class DocumentsTable(Table):
def __init__(self, documents): def __init__(self, documents, protocol):
super().__init__("Anhang", documents) super().__init__("Anhang", documents)
self.protocol = protocol
def headers(self): 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): 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): def row(self, document):
user = current_user() user = current_user()
...@@ -421,11 +438,15 @@ class DocumentsTable(Table): ...@@ -421,11 +438,15 @@ class DocumentsTable(Table):
links.append(Table.link(url_for("print_document", document_id=document.id), "Drucken")) links.append(Table.link(url_for("print_document", document_id=document.id), "Drucken"))
if document.protocol.protocoltype.has_admin_right(user): 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))) 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, document.id,
Table.link(url_for("download_document", document_id=document.id), document.name), 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): class TodoMailsTable(Table):
def __init__(self, todomails): def __init__(self, todomails):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment