973bf030af472151b7b2146c6a87e323e60e74a6
[wolnelektury.git] / src / api / urls.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 from django.conf.urls import url, include
6 from django.views.decorators.csrf import csrf_exempt
7 from django.views.generic import TemplateView
8 from piston.authentication import oauth_access_token, oauth_request_token
9 import catalogue.views
10 from api import handlers
11 from api.piston_patch import oauth_user_auth
12 from . import views
13
14
15 urlpatterns = [
16     url(r'^oauth/request_token/$', oauth_request_token),
17     url(r'^oauth/authorize/$', oauth_user_auth, name='oauth_user_auth'),
18     url(r'^oauth/access_token/$', csrf_exempt(oauth_access_token)),
19
20     url(r'^$', TemplateView.as_view(template_name='api/main.html'), name='api'),
21
22     # info boxes (used by mobile app)
23     url(r'book/(?P<book_id>\d*?)/info\.html$', catalogue.views.book_info),
24     url(r'tag/(?P<tag_id>\d*?)/info\.html$', catalogue.views.tag_info),
25
26     # reading data
27     url(r'^reading/(?P<slug>[a-z0-9-]+)/$', views.BookUserDataView.as_view(), name='api_reading'),
28     url(r'^reading/(?P<slug>[a-z0-9-]+)/(?P<state>[a-z]+)/$', views.BookUserDataView.as_view(), name='api_reading'),
29     url(r'^username/$', views.UserView.as_view(), name='api_username'),
30
31     url(r'^blog/$', views.BlogView.as_view()),
32
33     url(r'^pictures/$', include('picture.api.urls')),
34     url(r'^', include('social.api.urls')),
35     url(r'^', include('catalogue.api.urls')),
36 ]