From 590bda8730eb85f1897d7f17838bac8577931318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=AD=C3=B0ir=20Valberg=20Gu=C3=B0mundsson?= Date: Fri, 10 Jun 2016 20:31:38 +0200 Subject: [PATCH] News items can be non-public and thus are not timed for publication. --- news/templates/news_detail.html | 4 ++-- news/views.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/news/templates/news_detail.html b/news/templates/news_detail.html index 26f147a1..15eced7e 100644 --- a/news/templates/news_detail.html +++ b/news/templates/news_detail.html @@ -3,9 +3,9 @@ {% block content %}
- {% if draft %} + {% if not_public %}
- This news item is not yet public. It will become public at {{ news_item.published_at|date:'Y-m-d H:i' }}. + This news item is not yet public. {% if timed %}It will become public at {{ news_item.published_at|date:'Y-m-d H:i' }}.{% endif%}
{% endif %}

{{ news_item.title }} {{ news_item.published_at|date:"Y-m-d" }}

diff --git a/news/views.py b/news/views.py index 3e2af89a..6755f2fe 100644 --- a/news/views.py +++ b/news/views.py @@ -18,8 +18,14 @@ class NewsDetail(DetailView): def get_context_data(self, **kwargs): context = super(NewsDetail, self).get_context_data(**kwargs) news_item = self.get_object() - context['draft'] = False - if news_item.public and news_item.published_at > timezone.now(): - context['draft'] = True + timed = news_item.published_at > timezone.now() + + if news_item.public and timed: + context['not_public'] = True + context['timed'] = True + elif not news_item.public: + context['not_public'] = True + context['timed'] = False + return context