News items can be non-public and thus are not timed for publication.
This commit is contained in:
parent
ef00c130f9
commit
590bda8730
|
@ -3,9 +3,9 @@
|
|||
|
||||
{% block content %}
|
||||
<div>
|
||||
{% if draft %}
|
||||
{% if not_public %}
|
||||
<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>
|
||||
{% endif %}
|
||||
<h3>{{ news_item.title }} <small>{{ news_item.published_at|date:"Y-m-d" }}</small></h3>
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue