team-3/src/c3nav/editor/urls.py

23 lines
1.1 KiB
Python
Raw Normal View History

2016-08-31 17:14:31 +02:00
from django.conf.urls import url
2017-05-16 17:45:56 +02:00
from c3nav.editor.views import edit, list_objects, main_index, section_detail
2016-09-23 15:23:02 +02:00
2017-05-16 18:08:07 +02:00
2017-05-19 15:23:00 +02:00
def add_editor_urls(name, model, parent_name_plural=None, parent_name=None):
prefix = '' if parent_name is None else parent_name_plural+r'/(?P<'+parent_name+'>[0-9]+)/'
2017-05-16 18:08:07 +02:00
return [
2017-05-19 15:23:00 +02:00
url(r'^'+prefix+name+r'/$', list_objects, name='editor.'+name+'.list', kwargs={'model': model}),
url(r'^'+prefix+name+r'/(?P<pk>[0-9]+)/$', edit, name='editor.'+name+'.edit', kwargs={'model': model}),
url(r'^'+prefix+name+r'/create$', edit, name='editor.'+name+'.create', kwargs={'model': model}),
2017-05-16 18:08:07 +02:00
]
2016-08-31 17:14:31 +02:00
urlpatterns = [
2017-05-14 20:21:33 +02:00
url(r'^$', main_index, name='editor.index'),
url(r'^sections/(?P<pk>[0-9]+)/$', section_detail, name='editor.section'),
url(r'^sections/(?P<pk>[0-9]+)/edit$', edit, name='editor.section.edit', kwargs={'model': 'Section'}),
2017-05-16 15:51:56 +02:00
url(r'^sections/create$', edit, name='editor.section.create', kwargs={'model': 'Section'}),
2016-08-31 17:14:31 +02:00
]
2017-05-16 18:08:07 +02:00
urlpatterns.extend(add_editor_urls('locationgroups', 'LocationGroup'))
2017-05-19 15:23:00 +02:00
urlpatterns.extend(add_editor_urls('doors', 'Door', 'sections', 'section'))