from django.conf.urls import patterns, url

from .views import *
from .models import ClientCategory, Client, ClientOffice, ContactPerson

# someone should order things in here... :)

urlpatterns = patterns('',
                       # ---- clients ----

                       # clients overview
                       url(regex=r'^$',
                           view=ClientsListView.as_view(),
                           name=Client.overview_url),

                       # details for a client, including offices
                       url(regex=r'^(?P<pk>\d+)/$',
                           view=ClientDetailView.as_view(),
                           name=Client.detail_url),

                       # create client form
                       url(regex=r'^create/$',
                           view=ClientCreateView.as_view(),
                           name=Client.create_url),

                       url(regex=r'^update/(?P<pk>\d+)/$',
                           view=ClientUpdateView.as_view(),
                           name=Client.update_url),

                       # ==== offices ====

                       url(regex=r'^office/$',
                           view=ClientOfficesListView.as_view(),
                           name=ClientOffice.overview_url),

                       # details for a office of a client
                       url(regex=r'^office/(?P<pk>\d+)/$',
                           view=ClientOfficeDetailView.as_view(),
                           name=ClientOffice.detail_url),

                       url(regex=r'^office/create/$',
                           view=ClientOfficeCreateView.as_view(),
                           name=ClientOffice.create_url),

                       url(regex=r'^office/update/(?P<pk>\d+)/$',
                           view=ClientOfficeUpdateView.as_view(),
                           name=ClientOffice.update_url),

                       # ===== categories =====

                       # same story again and again, overview -> details -> create/update
                       url(regex=r'^category/$',
                           view=ClientCategoryListView.as_view(),
                           name=ClientCategory.overview_url),

                       url(regex=r'^category/(?P<pk>\d+)/$',
                           view=ClientCategoryDetailView.as_view(),
                           name=ClientCategory.detail_url),

                       url(regex=r'^category/create/$',
                           view=ClientCategoryCreateView.as_view(),
                           name=ClientCategory.create_url),

                       url(regex=r'^category/update/(?P<pk>\d+)/$',
                           view=ClientCategoryUpdateView.as_view(),
                           name=ClientCategory.update_url),

                       # ==== contacts ====

                       # overview for all contact persons across all clients
                       url(regex=r'^contacts/$',
                           view=ContactPersonsListView.as_view(),
                           name=ContactPerson.overview_url),

                       # detail view for a contact person
                       url(regex=r'^contacts/(?P<pk>\d+)/$',
                           view=ContactPersonDetailView.as_view(),
                           name=ContactPerson.detail_url),

                       # edit contact person for an office
                       url(regex=r'^contacts/update/(?P<pk>\d+)/$',
                           view=ContactPersonUpdateView.as_view(),
                           name=ContactPerson.update_url),

                       url(regex=r'^contacts/create/$',
                           view=ContactPersonCreateView.as_view(),
                           name=ContactPerson.create_url),
)
