cfecb5078acaeecba9a897f39bc69cdc669cc694
[wolnelektury.git] / src / wolnelektury / 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.conf import settings
5 from django.contrib import admin
6 from django.urls import include, path
7 from django.views.generic import RedirectView
8 import django.views.static
9 from annoy.utils import banner_exempt
10 import catalogue.views
11 import club.views
12 import picture.views
13 from . import views
14
15
16 urlpatterns = [
17     path('', views.main_page, name='main_page'),
18     path('planowane/', views.publish_plan, name='publish_plan'),
19     path('widget.html', views.widget, name='widget'),
20
21     path('zegar/', views.clock, name='clock'),
22
23     # Authentication
24     path('uzytkownik/', views.user_settings, name='user_settings'),
25     path('uzytkownik/login/', views.WLLoginView.as_view(), name='login'),
26     path('uzytkownik/signup/', views.WLRegisterView.as_view(), name='register'),
27     path('uzytkownik/logout/', views.logout_then_redirect, name='logout'),
28     path('uzytkownik/social/signup/', banner_exempt(views.SocialSignupView.as_view()), name='socialaccount_signup'),
29 ]
30
31 urlpatterns += [
32     path('eksperymenty/', include('experiments.urls')),
33     path('katalog/', include('catalogue.urls')),
34     path('opds/', include('opds.urls')),
35     path('sugestia/', include('suggest.urls')),
36     path('lesmianator/', include('lesmianator.urls')),
37     path('przypisy/', include('dictionary.urls')),
38     path('raporty/', include('reporting.urls')),
39     path('info/', include('infopages.urls')),
40     path('ludzie/', include('social.urls')),
41     path('uzytkownik/', include('allauth.urls')),
42     path('czekaj/', include('waiter.urls')),
43     path('wesprzyj/', include('funding.urls')),
44     path('ankieta/', include('polls.urls')),
45     path('biblioteki/', include('libraries.urls')),
46     path('mapa/', include('references.urls')),
47     path('newsletter/', include('newsletter.urls')),
48     path('formularz/', include('forms_builder.forms.urls')),
49     path('messaging/', include('messaging.urls')),
50     path('re/', include('redirects.urls')),
51     path('stats/', include('stats.urls')),
52     path('paypal/', include('paypal.urls')),
53     path('powiadomienie/', include('push.urls')),
54     path('pomagam/', include('club.urls')),
55     path('szkola-', include('education.urls')),
56     path('towarzystwo/notify/<int:pk>/',  club.views.PayUNotifyView.as_view(), name='club_payu_notify'),
57     path('towarzystwo/', RedirectView.as_view(url='/pomagam/', permanent=False, query_string=True)),
58     path('towarzystwo/<path:path>', RedirectView.as_view(
59         url='/pomagam/%(path)s', permanent=False)),
60     path('', include('bookmarks.urls')),
61
62     path('chunks/', include('chunks.urls')),
63
64     # Admin panel
65     path('admin/catalogue/book/import', catalogue.views.import_book, name='import_book'),
66     path('admin/catalogue/picture/import', picture.views.import_picture, name='import_picture'),
67     path('admin/doc/', include('django.contrib.admindocs.urls')),
68     path('admin/', admin.site.urls),
69
70     # API
71     path('api/', include('api.urls')),
72     # OAIPMH
73     path('oaipmh/', include('oai.urls')),
74
75     path('szukaj/', include('search.urls')),
76
77     path('i18n/', include('django.conf.urls.i18n')),
78 ]
79
80 urlpatterns += [
81     # old static pages - redirected
82     path('1procent/', RedirectView.as_view(
83         url='https://fundacja.wolnelektury.pl/pomoz-nam/1-procent/', permanent=True)),
84     path('epub/', RedirectView.as_view(
85         url='/katalog/lektury/', permanent=False)),
86     path('mozesz-nam-pomoc/', RedirectView.as_view(
87         url='/info/wlacz-sie-w-prace/', permanent=True)),
88     path('o-projekcie/', RedirectView.as_view(
89         url='/info/o-projekcie/', permanent=True)),
90     path('widget/', RedirectView.as_view(
91         url='/info/widget/', permanent=True)),
92     path('wolontariat/', RedirectView.as_view(
93         url='/info/wlacz-sie-w-prace/', permanent=False)),
94 ]
95
96
97 if settings.DEBUG:
98     import debug_toolbar
99     urlpatterns = [
100         path('__debug__/', include(debug_toolbar.urls)),
101     ] + urlpatterns
102
103 if settings.DEBUG:
104     import functools
105     from django.views.defaults import page_not_found, server_error
106     urlpatterns += [
107         path('error/500/', server_error),
108         path('error/404/', functools.partial(page_not_found, exception=None)),
109
110         # Static files
111         path('%s<path:path>' % settings.MEDIA_URL[1:], django.views.static.serve,
112            {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
113     ]