Refactor the 'entries' views into a package rather than just one module, so more views can be added without clutter

This commit is contained in:
Danielle McLean 2018-03-07 15:46:21 +11:00
parent cf0aea4f73
commit c359b7640e
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
5 changed files with 36 additions and 32 deletions

View file

@ -1,5 +1,6 @@
from django.conf.urls import url
from . import feeds, kinds, views
from . import kinds
from .views import feeds, lists, perma
from lemoncurry import breadcrumbs as crumbs
@ -18,7 +19,7 @@ app_name = 'entries'
urlpatterns = [
url('^atom$', feeds.AtomHomeEntries(), name='atom'),
url('^rss$', feeds.RssHomeEntries(), name='rss'),
url(to_pat('cats', slug, page), views.cat, name='cat'),
url(to_pat('cats', slug, page), lists.by_cat, name='cat'),
]
crumbs.add(prefix('cat'), parent='home:index')
@ -28,11 +29,11 @@ for k in kinds.all:
kind = k.plural
id = r'/(?P<id>\d+)'
urlpatterns += (
url(to_pat(kind, page), views.index, name=k.index, kwargs={'kind': k}),
url(to_pat(kind, page), lists.by_kind, name=k.index, kwargs={'kind': k}),
url(to_pat(kind, '/atom'), feeds.AtomByKind(k), name=k.atom),
url(to_pat(kind, '/rss'), feeds.RssByKind(k), name=k.rss),
url(to_pat(kind, id, slug, '/amp'), views.entry_amp, name=k.entry_amp),
url(to_pat(kind, id, slug), views.entry, name=k.entry),
url(to_pat(kind, id, slug, '/amp'), perma.entry_amp, name=k.entry_amp),
url(to_pat(kind, id, slug), perma.entry, name=k.entry),
)
crumbs.add(prefix(k.index), label=k.plural, parent='home:index')