new login api
[wolnelektury.git] / src / api / urls.py
1 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
3 #
4 from django.urls import path, include
5 from django.views.decorators.csrf import csrf_exempt
6 from django.views.generic import TemplateView
7 import catalogue.views
8 from stats.utils import piwik_track_view
9 from . import views
10
11
12 urlpatterns1 = [
13     path('register/', csrf_exempt(views.RegisterView.as_view())),
14     path('refreshToken/', csrf_exempt(views.RefreshTokenView.as_view())),
15     path('requestConfirm/', csrf_exempt(views.RequestConfirmView.as_view())),
16     path('login/', csrf_exempt(views.Login2View.as_view())),
17     path('me/', views.UserView.as_view()),
18     path('', include('catalogue.api.urls2')),
19 ]
20
21
22 urlpatterns = [
23     path('2/', include((urlpatterns1, 'api'), namespace="v2")),
24
25     path('oauth/request_token/', csrf_exempt(views.OAuth1RequestTokenView.as_view())),
26     path('oauth/authorize/', views.oauth_user_auth, name='oauth_user_auth'),
27     path('oauth/access_token/', csrf_exempt(views.OAuth1AccessTokenView.as_view())),
28     path('login/', csrf_exempt(views.LoginView.as_view())),
29
30     path('', TemplateView.as_view(template_name='api/main.html'), name='api'),
31
32     # info boxes (used by mobile app)
33     path('book/<int:book_id>/info.html', catalogue.views.book_info),
34     path('tag/<int:tag_id>/info.html', catalogue.views.tag_info),
35
36     # reading data
37     path('reading/<slug:slug>/',
38          piwik_track_view(views.BookUserDataView.as_view()),
39          name='api_reading'),
40     path('reading/<slug:slug>/<slug:state>/',
41          piwik_track_view(views.BookUserDataView.as_view()),
42          name='api_reading'),
43     path('username/',
44          piwik_track_view(views.UserView.as_view()),
45          name='api_username'),
46
47     path('blog',
48          piwik_track_view(views.BlogView.as_view())),
49
50     path('', include('social.api.urls')),
51     path('', include('catalogue.api.urls')),
52
53 ]