Remove stupid copyright notice
[styx.blog] / core / views.py
1 import datetime
2
3 from django.contrib.auth.models import User
4 from django.contrib.syndication.views import Feed
5 from django.utils.feedgenerator import Atom1Feed
6 from django.views.generic.detail import DetailView
7 from django.views.generic.list import ListView
8
9 from . import models
10
11 class AtomFeed(Feed):
12     feed_type = Atom1Feed
13
14     title = 'styx blog'
15     link = '/atom'
16     subtitle = 'styx blog'
17
18     def items(self):
19         now = datetime.datetime.utcnow()
20
21         return models.Post.objects.filter(
22             publication_utc__lte=now,
23         ).order_by('-publication_utc')
24
25 class PostDetailView(DetailView):
26     model = models.Post
27
28 class PostListView(ListView):
29     model = models.Post
30     paginate_by = 10
31
32     def get_queryset(self):
33         now = datetime.datetime.utcnow()
34
35         return super().get_queryset().filter(
36             publication_utc__lte=now,
37         ).order_by('-publication_utc')