from django.conf.urls import include, url
from django.views.generic import DetailView, ListView, TemplateView

from . import models

kingdoms_patterns = [
    url(r'^(?P<pk>[0-9]+)/$', DetailView.as_view(model=models.Kingdom), name='detail'),
    url(r'^$', ListView.as_view(model=models.Kingdom), name='list'),
]

territories_patterns = [
    url(r'^(?P<pk>[0-9]+)/$', DetailView.as_view(model=models.Territory), name='detail'),
    url(r'^$', ListView.as_view(model=models.Territory), name='list'),
]

nodes_patterns = [
    url(r'^(?P<pk>[0-9]+)/$', DetailView.as_view(model=models.Node), name='detail'),
    url(r'^$', ListView.as_view(model=models.Node), name='list'),
]

properties_patterns = [
    url(r'^(?P<pk>[0-9]+)/$', DetailView.as_view(model=models.Property), name='detail'),
    url(r'^$', ListView.as_view(model=models.Property), name='list'),
]

app_name = 'nodes'
urlpatterns = [
    url(r'^kingdoms/', include(kingdoms_patterns, namespace='kingdoms')),
    url(r'^territories/', include(territories_patterns, namespace='territories')),
    url(r'^nodes/', include(nodes_patterns, namespace='nodes')),
    url(r'^properties/', include(properties_patterns, namespace='properties')),
    url(r'^$', TemplateView.as_view(template_name='nodes/main.html'), name='main'),
]
