From b9550f0b757228ce18d5300d166ad1d0e152d071 Mon Sep 17 00:00:00 2001
From: Fredrik Jonsson <frjo@xdeb.org>
Date: Mon, 19 Aug 2019 11:21:48 +0200
Subject: [PATCH] Display created date instead of updated date for reviews. On
 detail page show updated as well if different from created.

---
 .../funds/templates/funds/includes/review_sidebar_item.html  | 2 +-
 opentech/apply/review/models.py                              | 5 +++++
 opentech/apply/review/templates/review/review_detail.html    | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/opentech/apply/funds/templates/funds/includes/review_sidebar_item.html b/opentech/apply/funds/templates/funds/includes/review_sidebar_item.html
index 955624c17..a8572ad45 100644
--- a/opentech/apply/funds/templates/funds/includes/review_sidebar_item.html
+++ b/opentech/apply/funds/templates/funds/includes/review_sidebar_item.html
@@ -17,7 +17,7 @@
                         {% if reviewer.role %}{% image reviewer.role.icon max-12x12 %}{% endif %}
                     </div>
                 </a>
-                <div class="reviews-sidebar__date">{{ reviewer.review.updated_at|date:"Y-m-d" }}</div>
+                <div class="reviews-sidebar__date">{{ reviewer.review.created_at|date:"Y-m-d" }}</div>
             </div>
         {% else %}
             <div class="reviews-sidebar__name">
diff --git a/opentech/apply/review/models.py b/opentech/apply/review/models.py
index 740f9d847..c9a9bf908 100644
--- a/opentech/apply/review/models.py
+++ b/opentech/apply/review/models.py
@@ -180,6 +180,11 @@ class Review(ReviewFormFieldsMixin, BaseStreamForm, AccessFormData, models.Model
     def reviewer_visibility(self):
         return self.visibility == REVIEWER
 
+    @cached_property
+    def is_updated(self):
+        # Only compear dates, not time.
+        return self.created_at.date() < self.updated_at.date()
+
 
 class ReviewOpinion(models.Model):
     review = models.ForeignKey(Review, on_delete=models.CASCADE, related_name='opinions')
diff --git a/opentech/apply/review/templates/review/review_detail.html b/opentech/apply/review/templates/review/review_detail.html
index 20264332d..970005efc 100644
--- a/opentech/apply/review/templates/review/review_detail.html
+++ b/opentech/apply/review/templates/review/review_detail.html
@@ -5,7 +5,7 @@
 <div class="admin-bar">
     <div class="admin-bar__inner">
         <h1 class="beta heading heading--no-margin heading--bold">Review</h1>
-        <h5>For <a href="{% url "funds:submissions:detail" review.submission.id %}">{{ review.submission.title }}</a> by {{ review.author }} at {{ review.updated_at|date:"Y-m-d" }}</h5>
+        <h5>For <a href="{% url "funds:submissions:detail" review.submission.id %}">{{ review.submission.title }}</a> by {{ review.author }} at {{ review.created_at|date:"Y-m-d" }} {% if review.is_updated %}<small>(Last updated: {{ review.updated_at|date:"Y-m-d" }})</small>{% endif %}</h5>
 
         {% include 'review/includes/review_opinions_list.html' with opinions=review.opinions.all %}
     </div>
-- 
GitLab