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
7 from api import handlers
8 from api.helpers import CsrfExemptResource
10 auth = OAuthAuthentication(realm="Edukacja Medialna")
12 lesson_list_resource = CsrfExemptResource(handler=handlers.LessonsHandler, authentication=auth)
13 lesson_resource = Resource(handler=handlers.LessonDetailHandler)
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)),
22 urlpatterns += patterns(
24 # url(r'^$', TemplateView.as_view(template_name='api/main.html'), name='api'),
27 url(r'^lessons/(?P<lesson>[a-z0-9-]+)/$', lesson_resource, name="api_lesson"),
30 url(r'^lessons/$', lesson_list_resource, name='api_lesson_list'),