From 7a3aab9198c7b750b228eeefc87f5ab7b5b853df Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Sun, 10 Mar 2019 06:06:44 +0100
Subject: [PATCH] Improve Forum/Meeting detail presentation

---
 forums/models.py                          | 13 +++++++
 forums/templates/forums/forum_detail.html | 45 ++++++++++++++++++-----
 forums/templates/forums/post_card.html    |  6 +--
 3 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/forums/models.py b/forums/models.py
index afa3f9c36..0af56c4ff 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 9d75e0e5c..bd98c87a0 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 3103355c1..64f1ba809 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 %}
-- 
GitLab