diff --git a/forums/models.py b/forums/models.py index afa3f9c3664f62d8e68ac340ef95650bef67f517..0af56c4ff26af66b4ff3395a019d44746dffd07e 100644 --- a/forums/models.py +++ b/forums/models.py @@ -132,6 +132,19 @@ class Meeting(Forum): self.date_from.strftime('%Y-%m-%d'), self.date_until.strftime('%Y-%m-%d')) + @property + def future(self): + return datetime.date.today() < self.date_from + + @property + def ongoing(self): + today = datetime.date.today() + return today >= self.date_from and today <= self.date_until + + @property + def past(self): + return datetime.date.today() > self.date_until + @property def context_colors(self): """If meeting is future: primary; ongoing: success; voting: warning; finished: info.""" diff --git a/forums/templates/forums/forum_detail.html b/forums/templates/forums/forum_detail.html index 9d75e0e5c5698cfa8431304d3ef4c3c508d2112a..bd98c87a05af146499d72358438050ad4d2b456c 100644 --- a/forums/templates/forums/forum_detail.html +++ b/forums/templates/forums/forum_detail.html @@ -16,12 +16,16 @@ {% get_obj_perms request.user for forum as "user_perms" %} {% block content %} + <div class="row"> <div class="col-12"> <h3 class="highlight"> {% if forum.meeting %} {% with context_colors=forum.meeting.context_colors %} - <span class="badge badge-{{ context_colors.bg }} mx-0 mb-2 p-2 text-{{ context_colors.text }}">{{ context_colors.message }}</span> + <span class="badge badge-{{ context_colors.bg }} mx-0 mb-2 p-2 text-{{ context_colors.text }}"> + {{ context_colors.message }} + <span class="small text-muted"> [{{ forum.meeting.date_from|date:"Y-m-d" }} to {{ forum.meeting.date_until|date:"Y-m-d" }}]</span> + </span> {% endwith %} <br/> {% endif %} @@ -40,6 +44,7 @@ {% endif %} {% if perms.forums.add_forum or "can_change_forum" in user_perms %} + <div class="container border border-danger"> <h4>Admin actions:</h4> <ul> <li><a href="{% url 'forums:forum_update' slug=forum.slug %}" class="text-warning">Update this {% if forum.meeting %}Meeting{% else %}Forum{% endif %}</a></li> @@ -82,30 +87,52 @@ </ul> </div> </div> - + </div> {% endif %} - <h3 class="highlight">Description</h3> + + <h3>Table of Contents</h3> + <ul> + <li><a href="#Description">Description</a></li> + {% if forum.meeting %} + <li><a href="#Motions">Motions</a></li> + {% endif %} + <li><a href="#Posts">Posts</a></li> + </ul> + + <h3 class="highlight" id="Description">Description</h3> {{ forum.description|restructuredtext }} + </div> +</div> - {% if forum.meeting %} - <h3 class="highlight">Motions</h3> +{% if forum.meeting %} +<div class="row"> + <div class="col-12"> + <h3 class="highlight" id="Motions">Motions</h3> <ul> + {% if forum.meeting.future %} + <li>Adding Motions will be activated once the meeting starts</li> + {% elif forum.meeting.past %} + <li><span class="text-danger">Adding Motions is deactivated</span> (Meeting is over)</li> + {% else %} <li><a href="{% url 'forums:motion_create' slug=forum.slug parent_model='forum' parent_id=forum.id %}">Add a new Motion</a></li> + {% endif %} </ul> {% for motion in forum.motions.all %} {% include 'forums/post_card.html' with forum=forum post=motion %} {% endfor %} - {% endif %} - - <h3 class="highlight">Posts</h3> + </div> +</div> +{% endif %} +<div class="row"> + <div class="col-12"> + <h3 class="highlight" id="Posts">Posts</h3> <ul> <li><a href="{% url 'forums:post_create' slug=forum.slug parent_model='forum' parent_id=forum.id %}">Add a new Post</a></li> </ul> - {% for post in forum.posts.all %} {% include 'forums/post_card.html' with forum=forum post=post %} {% endfor %} diff --git a/forums/templates/forums/post_card.html b/forums/templates/forums/post_card.html index 3103355c14777befa28dc6495d1c6e5395eea386..64f1ba809a0ae1714a24160b668efe76db16fd3d 100644 --- a/forums/templates/forums/post_card.html +++ b/forums/templates/forums/post_card.html @@ -1,6 +1,6 @@ {% load restructuredtext %} -<div class="card" id="post{{ post.id }}"> +<div class="card{% if post.motion %} text-white bg-dark{% endif %}" id="post{{ post.id }}"> <div class="card-header"> {{ post.subject }} <div class="postInfo"> @@ -26,7 +26,7 @@ {% if post.motion %} <div class="align-self-center px-2"> Voting results - <span class="text-muted"> + <span class="text-white-50"> {% if request.user in post.motion.in_agreement.all %} <br/>You have voted <span class="text-success">Agree</span> {% elif request.user in post.motion.in_doubt.all %} @@ -34,7 +34,7 @@ {% elif request.user in post.motion.in_disagreement.all %} <br/>You have voted <span class="text-danger">Disagree</span> {% elif request.user in post.motion.in_abstain.all %} - <br/>You have <span class="text-dark">Abstained</span> + <br/>You have <span class="text-white-50">Abstained</span> {% elif request.user in post.motion.eligible_for_voting.all %} <br/>[click to vote] {% endif %}