Gitlab CSE Unil

urls.py 1.53 KB
Newer Older
Julien Furrer's avatar
Julien Furrer committed
1
2
3
# coding=utf-8
from __future__ import unicode_literals

4
from django.conf.urls import url, include
5
6
from rest_framework.routers import DefaultRouter
from rest_framework_nested import routers
7
from rest_framework import urls as rest_framework_urls
8

9
from adim.serializers import SharedAnObjSerializer
10
11
from adim.views import AnObjViewSet, SharedAnObjViewSet, AnnotationViewSet, SharedAnnotationViewSet, UserViewSet

Julien Furrer's avatar
Julien Furrer committed
12

13
14
# Default router, as wee need the 'root-api' name
d_router = DefaultRouter()
Julien Furrer's avatar
Julien Furrer committed
15

16
router = routers.SimpleRouter()
Julien Furrer's avatar
Julien Furrer committed
17
18
19
router.register(r'anobjs', AnObjViewSet, base_name='anobjs')
router.register(r'shared/anobjs', SharedAnObjViewSet, base_name='shared-anobjs')
router.register(r'annotations', AnnotationViewSet, base_name='annotations')
20
router.register(r'users', UserViewSet, base_name='users')
Julien Furrer's avatar
Julien Furrer committed
21

22
23
24
25
26
27
annot_router = routers.NestedSimpleRouter(router, r'anobjs', lookup='anobjs')
annot_router.register(r'shared/annotations', SharedAnnotationViewSet, base_name='shared-annotations')

sh_annot_router = routers.NestedSimpleRouter(router, r'shared/anobjs', lookup='anobjs')
sh_annot_router.register(r'shared/annotations', SharedAnnotationViewSet, base_name='shared-annotations-2')

Julien Furrer's avatar
Julien Furrer committed
28
29
# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browseable API.
30
urlpatterns = [
31
    url(r'^$', d_router.get_api_root_view(), name='api-root'),
Julien Furrer's avatar
Julien Furrer committed
32
    url(r'^', include(router.urls)),
33
34
    url(r'^', include(annot_router.urls)),
    url(r'^', include(sh_annot_router.urls)),
35
36
    url(r'^api-auth/', include(rest_framework_urls, namespace='rest_framework'))
]