bornhack-website/src/news/views.py

24 lines
584 B
Python
Raw Normal View History

2016-06-05 21:20:06 +00:00
from django.views.generic import ListView, DetailView
from django.utils import timezone
2018-03-04 14:51:33 +00:00
from .models import NewsItem
2016-05-30 19:36:14 +00:00
class NewsIndex(ListView):
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
def get_queryset(self):
return NewsItem.objects.filter(
published_at__isnull=False,
published_at__lt=timezone.now(),
archived=self.kwargs['archived']
)
2016-06-05 21:20:06 +00:00
class NewsDetail(DetailView):
model = NewsItem
2016-06-05 21:20:06 +00:00
template_name = 'news_detail.html'
context_object_name = 'news_item'
2016-06-05 21:20:06 +00:00