From 69841be022156ba72ad4e5eab909bc345cde7762 Mon Sep 17 00:00:00 2001 From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de> Date: Tue, 18 Apr 2017 14:06:36 +0200 Subject: [PATCH] Add visual difference betwenn default-tops and tops /close #87 --- models/database.py | 14 +++++++++++++- static/css/style.css | 4 ++++ templates/protocol-tops-include.html | 4 ++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/models/database.py b/models/database.py index ffbedcd..5ecf463 100644 --- a/models/database.py +++ b/models/database.py @@ -6,7 +6,7 @@ from io import StringIO, BytesIO from enum import Enum from uuid import uuid4 -from shared import db, date_filter, date_filter_short, escape_tex, DATE_KEY, START_TIME_KEY, END_TIME_KEY +from shared import db, date_filter, date_filter_short, escape_tex, DATE_KEY, START_TIME_KEY, END_TIME_KEY, current_user from utils import random_string, url_manager, get_etherpad_url, split_terms, check_ip_in_networks from models.errors import DateNotMatchingException @@ -372,6 +372,18 @@ class LocalTOP(DatabaseModel): def get_parent(self): return self.protocol + def is_expandable(self): + user = current_user() + return (self.has_private_view_right(user) + and self.description is not None + and len(self.description) > 0) + + def get_css_classes(self): + classes = ["defaulttop"] + if self.is_expandable(): + classes.append("expansion-button") + return classes + class Document(DatabaseModel): __tablename__ = "documents" __model_name__ = "document" diff --git a/static/css/style.css b/static/css/style.css index 606b874..4473297 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -73,3 +73,7 @@ textarea { .like-sign { font-size: 16px; } + +li.defaulttop { + font-style: italic; +} diff --git a/templates/protocol-tops-include.html b/templates/protocol-tops-include.html index 7e9c43c..6be2c79 100644 --- a/templates/protocol-tops-include.html +++ b/templates/protocol-tops-include.html @@ -4,7 +4,7 @@ {% for default_top in protocol.protocoltype.default_tops %} {% if not default_top.is_at_end() %} {% set localtop = default_top.get_localtop(protocol) %} - <li{% if has_private_view_right and localtop.description is not none and localtop.description|length > 0 %} class="expansion-button" id="localtop-{{localtop.id}}" title="{{localtop.description}}"{% endif %}> + <li class="{{localtop.get_css_classes()|join(" ")}}" {% if localtop.is_expandable() %} id="localtop-{{localtop.id}}" title="{{localtop.description}}"{% endif %}> {{default_top.name}} {% if not protocol.is_done() and has_modify_right %} <a href="{{url_for('edit_localtop', localtop_id=localtop.id)}}">Ändern</a> @@ -44,7 +44,7 @@ {% for default_top in protocol.protocoltype.default_tops %} {% if default_top.is_at_end() %} {% set localtop = default_top.get_localtop(protocol) %} - <li{% if has_private_view_right and localtop.description is not none and localtop.description|length > 0 %} class="expansion-button" id="localtop-{{localtop.id}}" title="{{localtop.description}}"{% endif %}> + <li class="{{localtop.get_css_classes()|join(" ")}}" {% if localtop.is_expandable() %} id="localtop-{{localtop.id}}" title="{{localtop.description}}"{% endif %}> {{default_top.name}} {% if not protocol.is_done() and has_modify_right %} <a href="{{url_for('edit_localtop', localtop_id=localtop.id)}}">Ändern</a> -- GitLab