2016-06-05 21:20:06 +00:00
|
|
|
from django.views.generic import ListView, DetailView
|
2016-06-10 18:21:32 +00:00
|
|
|
from django.utils import timezone
|
2016-12-25 14:52:55 +00:00
|
|
|
from .models import *
|
2016-05-30 19:36:14 +00:00
|
|
|
|
|
|
|
class NewsIndex(ListView):
|
2016-12-25 14:52:55 +00:00
|
|
|
model = NewsItem
|
2016-05-30 19:36:14 +00:00
|
|
|
template_name = 'news_index.html'
|
|
|
|
context_object_name = 'news_items'
|
2016-06-05 21:20:06 +00:00
|
|
|
|
2017-01-20 15:18:10 +00:00
|
|
|
def get_queryset(self):
|
2016-12-25 14:52:55 +00:00
|
|
|
return NewsItem.objects.filter(
|
|
|
|
published_at__isnull=False,
|
|
|
|
published_at__lt=timezone.now(),
|
2017-01-20 15:18:10 +00:00
|
|
|
archived=self.kwargs['archived']
|
2016-12-25 14:52:55 +00:00
|
|
|
)
|
2016-06-16 16:46:52 +00:00
|
|
|
|
2016-06-05 21:20:06 +00:00
|
|
|
|
|
|
|
class NewsDetail(DetailView):
|
2016-12-25 14:52:55 +00:00
|
|
|
model = NewsItem
|
2016-06-05 21:20:06 +00:00
|
|
|
template_name = 'news_detail.html'
|
2016-06-05 21:34:30 +00:00
|
|
|
context_object_name = 'news_item'
|
2016-06-05 21:20:06 +00:00
|
|
|
|