From d28d3f3bfc145abe94e4f202aee26b3078f308ed Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Wed, 13 Apr 2016 15:15:43 +0200 Subject: [PATCH] Consistently use standard date formats for news entries This appears to have become dependent on a django setting that we no longer set -- and it's best to have a predictable format regardless. Most things on the frontpage used the standard format, but not news, leading to an annoyingly inconsistent view. --- pgweb/news/models.py | 4 ++++ templates/index.html | 2 +- templates/news/item.html | 2 +- templates/news/newsarchive.html | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pgweb/news/models.py b/pgweb/news/models.py index 330f2032..77a8fa04 100644 --- a/pgweb/news/models.py +++ b/pgweb/news/models.py @@ -30,5 +30,9 @@ class NewsArticle(models.Model): return True return False + @property + def displaydate(self): + return self.date.strftime("%Y-%m-%d") + class Meta: ordering = ('-date',) diff --git a/templates/index.html b/templates/index.html index 884b832a..c3e46efb 100644 --- a/templates/index.html +++ b/templates/index.html @@ -103,7 +103,7 @@
{% for n in news %}

- {{n.date}}
+ {{n.displaydate}}
{{n.title}}

{% endfor %} diff --git a/templates/news/item.html b/templates/news/item.html index 1399fb22..6b9f970e 100644 --- a/templates/news/item.html +++ b/templates/news/item.html @@ -3,7 +3,7 @@ {%block title%}{{obj.title}}{%endblock%} {%block contents%}

{{obj.title}}

-
Posted on {{obj.date}}
+
Posted on {{obj.displaydate}}
{{obj.content|markdown}} {%if obj.is_migrated%}

This post has been migrated from a previous version of the PostgreSQL diff --git a/templates/news/newsarchive.html b/templates/news/newsarchive.html index 4c552605..93f7d034 100644 --- a/templates/news/newsarchive.html +++ b/templates/news/newsarchive.html @@ -5,7 +5,7 @@

News archive

{%for obj in news %}

{{obj.title}}

-
Posted on {{obj.date}}
+
Posted on {{obj.displaydate}}
{{obj.content|markdown|striptags|truncatewords:20}} {%endfor%}

Submit news

-- 2.39.5