edit buttons
[wolnelektury.git] / src / wolnelektury / urls.py
index 58e45dd..4de5f49 100644 (file)
-# -*- coding: utf-8 -*-
 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
-from django.conf.urls import include, patterns, url
 from django.conf import settings
 from django.contrib import admin
+from django.urls import include, path
 from django.views.generic import RedirectView
-import wolnelektury.views
+import django.views.static
+from annoy.utils import banner_exempt
+import catalogue.views
+import club.views
+import picture.views
+from . import views
 
 
-urlpatterns = patterns('wolnelektury.views',
-    url(r'^$', 'main_page', name='main_page'),
-    url(r'^planowane/$', 'publish_plan', name='publish_plan'),
-    url(r'^widget\.html$', 'widget', name='widget'),
+urlpatterns = [
+    path('', views.main_page, name='main_page'),
+    path('planowane/', views.publish_plan, name='publish_plan'),
+    path('widget.html', views.widget, name='widget'),
 
-    url(r'^zegar/$', 'clock', name='clock'),
+    path('zegar/', views.clock, name='clock'),
 
     # Authentication
-    url(r'^uzytkownik/$', 'user_settings', name='user_settings'),
-    url(r'^uzytkownik/login/$', wolnelektury.views.LoginFormView(), name='login'),
-    url(r'^uzytkownik/signup/$', wolnelektury.views.RegisterFormView(), name='register'),
-    url(r'^uzytkownik/logout/$', 'logout_then_redirect', name='logout'),
-    url(r'^uzytkownik/zaloguj-utworz/$', wolnelektury.views.LoginRegisterFormView(), name='login_register'),
+    path('uzytkownik/', views.user_settings, name='user_settings'),
+    path('uzytkownik/login/', banner_exempt(views.LoginFormView()), name='login'),
+    path('uzytkownik/signup/', banner_exempt(views.RegisterFormView()), name='register'),
+    path('uzytkownik/logout/', views.logout_then_redirect, name='logout'),
+    path('uzytkownik/zaloguj-utworz/', banner_exempt(views.LoginRegisterFormView()), name='login_register'),
+    path('uzytkownik/social/signup/', banner_exempt(views.SocialSignupView.as_view()), name='socialaccount_signup'),
+]
 
-    # Includes.
-    url(r'^latests_blog_posts.html$',
-        wolnelektury.views.latest_blog_posts,
-        name='latest_blog_posts'),
-)
+urlpatterns += [
+    path('eksperymenty/', include('experiments.urls')),
+    path('katalog/', include('catalogue.urls')),
+    path('opds/', include('opds.urls')),
+    path('sugestia/', include('suggest.urls')),
+    path('lesmianator/', include('lesmianator.urls')),
+    path('przypisy/', include('dictionary.urls')),
+    path('raporty/', include('reporting.urls')),
+    path('info/', include('infopages.urls')),
+    path('ludzie/', include('social.urls')),
+    path('uzytkownik/', include('allauth.urls')),
+    path('czekaj/', include('waiter.urls')),
+    path('wesprzyj/', include('funding.urls')),
+    path('ankieta/', include('polls.urls')),
+    path('biblioteki/', include('libraries.urls')),
+    path('newsletter/', include('newsletter.urls')),
+    path('formularz/', include('forms_builder.forms.urls')),
+    path('isbn/', include('isbn.urls')),
+    path('messaging/', include('messaging.urls')),
+    path('re/', include('redirects.urls')),
+    path('stats/', include('stats.urls')),
+    path('paypal/', include('paypal.urls')),
+    path('powiadomienie/', include('push.urls')),
+    path('pomagam/', include('club.urls')),
+    path('towarzystwo/notify/<int:pk>/',  club.views.PayUNotifyView.as_view(), name='club_payu_notify'),
+    path('towarzystwo/', RedirectView.as_view(url='/pomagam/', permanent=False, query_string=True)),
+    path('towarzystwo/<path:path>', RedirectView.as_view(
+        url='/pomagam/%(path)s', permanent=False)),
 
-urlpatterns += patterns('',
-    url(r'^katalog/', include('catalogue.urls')),
-    url(r'^opds/', include('opds.urls')),
-    url(r'^sugestia/', include('suggest.urls')),
-    url(r'^lesmianator/', include('lesmianator.urls')),
-    url(r'^przypisy/', include('dictionary.urls')),
-    url(r'^raporty/', include('reporting.urls')),
-    url(r'^info/', include('infopages.urls')),
-    url(r'^ludzie/', include('social.urls')),
-    url(r'^uzytkownik/', include('allauth.urls')),
-    url(r'^czekaj/', include('waiter.urls')),
-    url(r'^wesprzyj/', include('funding.urls')),
-    url(r'^ankieta/', include('polls.urls')),
-    url(r'^biblioteki/', include('libraries.urls')),
-    url(r'^chunks/', include('chunks.urls')),
-    url(r'^sponsors/', include('sponsors.urls')),
+    path('chunks/', include('chunks.urls')),
 
     # Admin panel
-    url(r'^admin/catalogue/book/import$', 'catalogue.views.import_book', name='import_book'),
-    url(r'^admin/catalogue/picture/import$', 'picture.views.import_picture', name='import_picture'),
-    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
-    url(r'^admin/', include(admin.site.urls)),
+    path('admin/catalogue/book/import', catalogue.views.import_book, name='import_book'),
+    path('admin/catalogue/picture/import', picture.views.import_picture, name='import_picture'),
+    path('admin/doc/', include('django.contrib.admindocs.urls')),
+    path('admin/', admin.site.urls),
 
     # API
-    (r'^api/', include('api.urls')),
+    path('api/', include('api.urls')),
     # OAIPMH
-    (r'^oaipmh/', include('oai.urls')),
+    path('oaipmh/', include('oai.urls')),
 
-    url(r'^szukaj/', include('search.urls')),
+    path('szukaj/', include('search.urls')),
 
-    # Static files
-    url(r'^%s(?P<path>.*)$' % settings.MEDIA_URL[1:], 'django.views.static.serve',
-        {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
-    url(r'^%s(?P<path>.*)$' % settings.STATIC_URL[1:], 'django.views.static.serve',
-        {'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
-    url(r'^i18n/', include('django.conf.urls.i18n')),
-)
+    path('i18n/', include('django.conf.urls.i18n')),
+    path('forum/', include('machina.urls')),
+]
 
-urlpatterns += patterns('',
+urlpatterns += [
     # old static pages - redirected
-    url(r'^1procent/$', RedirectView.as_view(
+    path('1procent/', RedirectView.as_view(
         url='http://nowoczesnapolska.org.pl/wesprzyj_nas/', permanent=True)),
-    url(r'^epub/$', RedirectView.as_view(
+    path('epub/', RedirectView.as_view(
         url='/katalog/lektury/', permanent=False)),
-    url(r'^mozesz-nam-pomoc/$', RedirectView.as_view(
-        url='/info/mozesz-nam-pomoc', permanent=True)),
-    url(r'^o-projekcie/$', RedirectView.as_view(
-        url='/info/o-projekcie', permanent=True)),
-    url(r'^widget/$', RedirectView.as_view(
-        url='/info/widget', permanent=True)),
-    url(r'^wolontariat/$', RedirectView.as_view(
-        url='/info/mozesz-nam-pomoc/', permanent=False)),
-)
+    path('mozesz-nam-pomoc/', RedirectView.as_view(
+        url='/info/wlacz-sie-w-prace/', permanent=True)),
+    path('o-projekcie/', RedirectView.as_view(
+        url='/info/o-projekcie/', permanent=True)),
+    path('widget/', RedirectView.as_view(
+        url='/info/widget/', permanent=True)),
+    path('wolontariat/', RedirectView.as_view(
+        url='/info/wlacz-sie-w-prace/', permanent=False)),
+]
+
+urlpatterns += [
+    # path('error-test/', views.exception_test),
+    # path('post-test/', views.post_test),
+]
+
+
+if settings.DEBUG:
+    import debug_toolbar
+    urlpatterns = [
+        path('__debug__/', include(debug_toolbar.urls)),
+    ] + urlpatterns
+
+if settings.DEBUG:
+    urlpatterns += [
+        # Static files
+        path('%s<path:path>' % settings.MEDIA_URL[1:], django.views.static.serve,
+           {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
+    ]