republish lessons - fix attachments
[edumed.git] / api / urls.py
1 # -*- coding: utf-8 -*-
2 from django.conf.urls import patterns, url
3 from django.views.decorators.csrf import csrf_exempt
4 from piston.authentication import OAuthAuthentication, oauth_access_token
5 from piston.resource import Resource
6
7 from api import handlers
8 from api.helpers import CsrfExemptResource
9
10 auth = OAuthAuthentication(realm="Edukacja Medialna")
11
12 lesson_list_resource = CsrfExemptResource(handler=handlers.LessonsHandler, authentication=auth)
13 lesson_resource = Resource(handler=handlers.LessonDetailHandler)
14
15 urlpatterns = patterns(
16     'piston.authentication',
17     url(r'^oauth/request_token/$', 'oauth_request_token'),
18     url(r'^oauth/authorize/$', 'oauth_user_auth'),
19     url(r'^oauth/access_token/$', csrf_exempt(oauth_access_token)),
20 )
21
22 urlpatterns += patterns(
23     '',
24     # url(r'^$', TemplateView.as_view(template_name='api/main.html'), name='api'),
25
26     # objects details
27     url(r'^lessons/(?P<lesson>[a-z0-9-]+)/$', lesson_resource, name="api_lesson"),
28
29     # lessons
30     url(r'^lessons/$', lesson_list_resource, name='api_lesson_list'),
31 )