2017-10-28 21:41:33 -04:00
|
|
|
from annoying.decorators import render_to
|
2018-03-06 23:46:21 -05:00
|
|
|
from django.shortcuts import get_object_or_404
|
2017-12-14 20:34:02 -05:00
|
|
|
from django.urls import reverse
|
2018-03-06 23:46:21 -05:00
|
|
|
from ..models import Entry, Cat
|
|
|
|
from ..pagination import paginate
|
2017-10-24 21:01:52 -04:00
|
|
|
|
|
|
|
|
2023-08-10 02:52:37 -04:00
|
|
|
@render_to("entries/index.html")
|
2018-05-03 22:13:52 -04:00
|
|
|
def by_kind(request, kind, page=None):
|
2017-12-14 20:34:02 -05:00
|
|
|
entries = Entry.objects.filter(kind=kind.id)
|
2018-03-07 21:49:02 -05:00
|
|
|
entries = paginate(queryset=entries, reverse=kind.index_page, page=page)
|
2017-12-12 02:35:13 -05:00
|
|
|
|
2017-10-31 18:29:59 -04:00
|
|
|
return {
|
2023-08-10 02:52:37 -04:00
|
|
|
"entries": entries,
|
|
|
|
"atom": kind.atom,
|
|
|
|
"rss": kind.rss,
|
|
|
|
"title": kind.plural,
|
2017-10-31 18:29:59 -04:00
|
|
|
}
|
2017-10-24 21:31:08 -04:00
|
|
|
|
|
|
|
|
2023-08-10 02:52:37 -04:00
|
|
|
@render_to("entries/index.html")
|
2018-05-03 22:13:52 -04:00
|
|
|
def by_cat(request, slug, page=None):
|
2017-12-14 20:34:02 -05:00
|
|
|
def url(page):
|
2023-08-10 02:52:37 -04:00
|
|
|
kwargs = {"slug": slug}
|
2017-12-14 20:34:02 -05:00
|
|
|
if page > 1:
|
2023-08-10 02:52:37 -04:00
|
|
|
kwargs["page"] = page
|
|
|
|
return reverse("entries:cat", kwargs=kwargs)
|
2017-12-14 20:34:02 -05:00
|
|
|
|
2017-11-19 19:09:30 -05:00
|
|
|
cat = get_object_or_404(Cat, slug=slug)
|
2017-12-14 20:34:02 -05:00
|
|
|
entries = cat.entries.all()
|
|
|
|
entries = paginate(queryset=entries, reverse=url, page=page)
|
2017-12-12 17:56:18 -05:00
|
|
|
|
2017-11-19 18:59:03 -05:00
|
|
|
return {
|
2023-08-10 02:52:37 -04:00
|
|
|
"entries": entries,
|
|
|
|
"title": "#" + cat.name,
|
2017-11-19 18:59:03 -05:00
|
|
|
}
|