Make entry kinds a teeny bit easier to manage by moving some of the smarts into the actual kinds.Entry class
This commit is contained in:
parent
dc99e7a39b
commit
f39782346f
3 changed files with 38 additions and 21 deletions
|
|
@ -5,20 +5,18 @@ from lemoncurry import breadcrumbs
|
|||
app_name = 'entries'
|
||||
urlpatterns = []
|
||||
for k in kinds.all:
|
||||
index = k.plural + '_index'
|
||||
urlpatterns.append(
|
||||
url(r'^{k}$'.format(k=k.plural), views.index, name=index, kwargs={'kind': k})
|
||||
url(r'^{k}$'.format(k=k.plural), views.index, name=k.index, kwargs={'kind': k})
|
||||
)
|
||||
breadcrumbs.add(app_name + ':' + index, label=k.plural, parent='home:index')
|
||||
breadcrumbs.add(app_name + ':' + k.index, label=k.plural, parent='home:index')
|
||||
|
||||
entry = k.plural + '_entry'
|
||||
pattern = r'^{k}/(?P<id>\d+)'.format(k=k.plural)
|
||||
urlpatterns.append(
|
||||
url(pattern + '$', views.entry, name=entry)
|
||||
url(pattern + '$', views.entry, name=k.entry)
|
||||
)
|
||||
breadcrumbs.add(app_name + ':' + entry, parent=app_name + ':' + index)
|
||||
breadcrumbs.add(app_name + ':' + k.entry, parent=app_name + ':' + k.index)
|
||||
if k.has('slug'):
|
||||
urlpatterns.append(
|
||||
url(pattern + r'/(?P<slug>.+)$', views.entry, name=entry + '_slug')
|
||||
url(pattern + r'/(?P<slug>.+)$', views.entry, name=k.entry_slug)
|
||||
)
|
||||
breadcrumbs.add(app_name + ':' + entry + '_slug', parent=app_name + ':' + index)
|
||||
breadcrumbs.add(app_name + ':' + k.entry_slug, parent=app_name + ':' + k.index)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue