News items can be non-public and thus are not timed for publication.

This commit is contained in:
Víðir Valberg Guðmundsson 2016-06-10 20:31:38 +02:00
parent ef00c130f9
commit 590bda8730
2 changed files with 11 additions and 5 deletions

View file

@ -3,9 +3,9 @@
{% block content %} {% block content %}
<div> <div>
{% if draft %} {% if not_public %}
<div class="alert alert-danger"> <div class="alert alert-danger">
<strong>This news item is not yet public.</strong> It will become public at {{ news_item.published_at|date:'Y-m-d H:i' }}. <strong>This news item is not yet public.</strong> {% if timed %}It will become public at {{ news_item.published_at|date:'Y-m-d H:i' }}.{% endif%}
</div> </div>
{% endif %} {% endif %}
<h3>{{ news_item.title }} <small>{{ news_item.published_at|date:"Y-m-d" }}</small></h3> <h3>{{ news_item.title }} <small>{{ news_item.published_at|date:"Y-m-d" }}</small></h3>

View file

@ -18,8 +18,14 @@ class NewsDetail(DetailView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(NewsDetail, self).get_context_data(**kwargs) context = super(NewsDetail, self).get_context_data(**kwargs)
news_item = self.get_object() news_item = self.get_object()
context['draft'] = False timed = news_item.published_at > timezone.now()
if news_item.public and news_item.published_at > timezone.now():
context['draft'] = True 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 return context