urls.py 1.07 KB
Newer Older
1
2
3
4
5
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django.conf.urls import patterns, include, url
# imports from your apps
6
7
from .views import BuildingList, BuildingRetrieve, FloorRetrieve, RoomRetrieve,\
                   MajorList, MajorRetrieve
8

9
10
11
12
# custom routing ftw
# separate out major and building patterns
building_urls = patterns('',
    url(r'^$', BuildingList.as_view(), name='api_list_buildings'),
13
14
    url(r'^(?P<name>[\w-]+)/$', BuildingRetrieve.as_view(), name='api_detail_building'),
    url(r'^building/(?P<pk>\d+)/$', FloorRetrieve.as_view(), name='api_detail_floor'),
15
    # list all the floors still?
16
    url(r'^building/floor/(?P<pk>\d+)/$', RoomRetrieve.as_view(), name='api_deatil_room'),
17
18
    # list all the rooms still?
)
19

20
21
22
23
major_urls = patterns('',
    url(r'^$', MajorList.as_view(), name='api_list_majors'),
    url(r'^(?P<pk>\d+)/$', MajorRetrieve.as_view(), name='api_detail_building'),
)
24

25
26
27
28
urlpatterns = patterns('',
    url(r'^housing/', include(building_urls)),
    url(r'^majors/', include(major_urls)),
)