diff --git a/models/database.py b/models/database.py index f97fc04f99564cae697003bc4d85b79e83fc4c25..8eed90e4384572b330fef722c2174672311bb3d0 100644 --- a/models/database.py +++ b/models/database.py @@ -237,6 +237,24 @@ class Protocol(DatabaseModel): def is_done(self): return self.done + def get_state_glyph(self): + if self.is_done(): + state = "unchecked" #"Fertig" + if self.public: + state = "check" #"Veröffentlicht" + else: + state = "pencil" #"Geplant" + return state + + def get_state_name(self): + if self.is_done(): + state = "Fertig" + if self.public: + state = "Veröffentlicht" + else: + state = "Geplant" + return state + def get_identifier(self): if self.pad_identifier is not None: return self.pad_identifier diff --git a/templates/macros.html b/templates/macros.html index ca9da0a58f955bba54375739be69c2b5de7797ea..0408a6c06eaba8a19b65b4f06d895fd30d5abc94 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -126,7 +126,7 @@ to not render a label for the CRSFTokenField --> <a href="{{table.newlink}}">{{table.newtext}}</a> {% endif %} </h3> - <table class="table table-striped"> + <table class="table table-striped table-hover"> <thead> <tr> {% for (header, class) in zip(table.headers(), classes) %} diff --git a/templates/protocols-list.html b/templates/protocols-list.html index 1b1f81fa7ceab7cdf50de78ab9bf967ca9dcb86d..02d3c81ee505e06950b72655f09d17243aa5a886 100644 --- a/templates/protocols-list.html +++ b/templates/protocols-list.html @@ -12,10 +12,16 @@ <a href="{{url_for(request.endpoint, page=_page, protocoltype_id=protocoltype_id, search=search_term, state_open=state_open, page_length=_page_length)}}">{{text}}</a> {% endmacro %} + + {% block content %} <div class="container"> {{render_form(search_form, class_="form-inline", action_url=url_for("list_protocols"), action_text="Suchen", labels_visible=False, method="GET")}} {{render_table(protocols_table)}} +<div align="center"> <span class="glyphicon glyphicon-pencil"></span> Geplant, + <span class="glyphicon glyphicon-unchecked"></span> Fertig, + <span class="glyphicon glyphicon-check"></span> Veröffentlicht +</div> {% include "pagination-footer.html" %} </div> {% endblock %} diff --git a/views/tables.py b/views/tables.py index f963283a1f5daeb5854fda767dca34522b919e19..48842b110223cb969097624173b7363c1c3902e1 100644 --- a/views/tables.py +++ b/views/tables.py @@ -25,6 +25,16 @@ class Table: confirmation = " onclick=\"return confirm('{}');\"".format(confirm) return Markup("<a href=\"{}\"{}>{}</a>".format(target, confirmation, text)) + @staticmethod + def button(target, icon, style, confirm=None): + confirmation = "" + if confirm: + confirmation = " onclick=\"return confirm('{}');\"".format(confirm) + return Markup( + '''<a href="{target}" class="btn btn-{style}" {confirmation}> + <span class="glyphicon glyphicon-{icon}"></span> + </a>'''.format(target=target, style=style, confirmation=confirmation, icon=icon)) + @staticmethod def mail(target): return Markup("<a href=\"mailto:{}\">{}</a>".format(target, target)) @@ -59,54 +69,58 @@ class ProtocolsTable(Table): def headers(self): user = current_user() - result = ["ID", "Sitzung", "Sitzung", "Datum"] - state_part = ["Status"] - search_part = ["Suchergebnis"] - login_part = ["Typ", ""] + result = ["Sitzung", "Sitzung", "Datum"] + state_part = ["Status", "Status",""] + search_part = ["Suchergebnis",""] if self.search_results is None: result.extend(state_part) else: result.extend(search_part) - if check_login(): - result.extend(login_part) return result def classes(self): - state_or_search_class = "hidden-xs" if self.search_results is None else None - result = ["hidden-xs", "hidden-sm hidden-md hidden-lg", "hidden-xs", "hidden-xs", None] - #result.append(state_or_search_class) - login_part = ["hidden-xs", "hidden-xs"] - if check_login(): - result.extend(login_part) + if self.search_results is None: + result = ["hidden-sm hidden-md hidden-lg", "hidden-xs", "hidden-xs", "hidden-sm hidden-md hidden-lg", "hidden-xs", ""] + else: + result = ["hidden-sm hidden-md hidden-lg", "hidden-xs", "hidden-xs", "", "hidden-xs","hidden-xs"] return result def row(self, protocol): user = current_user() protocol_link = url_for("show_protocol", protocol_id=protocol.id) result = [ - Table.link(protocol_link, str(protocol.id)), Markup("<br>").join([Table.link(protocol_link, protocol.protocoltype.name), date_filter(protocol.date)]), Table.link(protocol_link, protocol.protocoltype.name), date_filter(protocol.date), ] if self.search_results is None: - state = "Geplant" - if protocol.is_done(): - state = "Fertig" - if protocol.public: - state = "Veröffentlicht" - result.append(state) + result.append(Markup('<span class="glyphicon glyphicon-{state}"></span>'.format(state=protocol.get_state_glyph()))) + result.append(Markup('<span class="glyphicon glyphicon-{glyph}"></span> {state}'.format(state=protocol.get_state_name(),glyph=protocol.get_state_glyph()))) elif protocol in self.search_results: result.append(Markup(self.search_results[protocol])) - if check_login(): - if user is not None and protocol.protocoltype.has_private_view_right(user): - 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_short_identifier()))) - else: - result.append("") - else: - result.extend(["", ""]) + result.append(Markup('<span class="glyphicon glyphicon-{state}"></span>'.format(state=protocol.get_state_glyph()))) + + login_part1="" + login_part2="" + if protocol.has_public_view_right(user): + user_right = protocol.has_private_view_right(user) + document = protocol.get_compiled_document(user_right) + if document is not None: + login_part1 = Table.button( + url_for("download_document", document_id=document.id), + icon="download", style="success") + + if protocol.protocoltype.has_admin_right(user): + login_part2 = Table.button( + url_for("delete_protocol", protocol_id=protocol.id), + icon="trash", + style="danger", + confirm="Bist du dir sicher, dass du das Protokoll {} löschen möchtest?") + + result.append(Markup( + '<div class="btn-group btn-group-xs"> {} </div>'.format( + "".join((login_part1, login_part2))))) + return result class ProtocolTypesTable(Table):