From b95b09260db87f6665bfcef3fb4f7c19f8acb666 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 14 Feb 2019 22:21:19 +0100 Subject: [PATCH 1/1] Django 1.9. --- requirements/requirements.txt | 19 ++-- src/api/urls.py | 2 +- src/catalogue/models/book.py | 4 +- src/catalogue/models/collection.py | 1 - src/catalogue/urls.py | 103 ++++++++---------- src/catalogue/views.py | 1 - src/chunks/urls.py | 11 +- src/contact/admin.py | 8 +- src/contact/urls.py | 8 +- src/dictionary/urls.py | 7 +- src/funding/urls.py | 41 ++++--- src/funding/views.py | 4 +- src/infopages/urls.py | 10 +- src/lesmianator/urls.py | 19 ++-- src/libraries/urls.py | 14 +-- src/oai/handlers.py | 1 - src/oai/urls.py | 9 +- src/opds/urls.py | 7 +- src/paypal/tests.py | 16 ++- src/picture/models.py | 28 ----- src/picture/views.py | 21 ---- src/polls/urls.py | 10 +- src/push/urls.py | 8 +- src/reporting/urls.py | 14 +-- src/search/urls.py | 13 ++- src/social/urls.py | 31 ++---- src/sponsors/urls.py | 11 +- src/suggest/urls.py | 7 +- src/waiter/urls.py | 10 +- src/wolnelektury/settings/apps.py | 1 - src/wolnelektury/settings/basic.py | 8 +- src/wolnelektury/settings/static.py | 5 - .../templates/base/superbase.html | 2 +- src/wolnelektury/templates/openid/login.html | 18 +-- .../templates/socialaccount/connections.html | 12 +- 35 files changed, 204 insertions(+), 280 deletions(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 7122431cf..fd98553b0 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,15 +1,15 @@ --i https://py.mdrn.pl:8443/simple/ +-i https://py.mdrn.pl/simple/ # django -Django>=1.8,<1.9 +Django>=1.9,<1.10 fnpdjango>=0.2.8,<0.3 django-pipeline>=1.6,<1.7 jsmin fnp-django-pagination django-maintenancemode==0.10 -jsonfield>=1.0.3,<1.1 +jsonfield==2.0.2 django-picklefield>=1.0,<1.1 -django-modeltranslation>=0.10,<0.11 +django-modeltranslation==0.11 django-allauth>=0.32,<0.33 django-extensions djangorestframework<3.7 @@ -20,12 +20,11 @@ oauthlib>=3.0.1,<3.1 pyyaml polib -django-babel +django-babel==0.5.0 pytz -django-honeypot -django-uni-form +django-honeypot==0.6.0 python-memcached django-piwik @@ -57,10 +56,12 @@ pyoai==2.4.4 ## egenix-mx-base # Doesn't play nice with mx in dist-packages. sunburnt -django-getpaid>=1.7,<1.8 +#django-getpaid==1.7.4 +-e git+https://github.com/django-getpaid/django-getpaid.git@v1.7.4#egg=django-getpaid + httplib2 Texml -django-ssify>=0.2.1,<0.3 +django-ssify>=0.2.6,<0.3 raven diff --git a/src/api/urls.py b/src/api/urls.py index 16fdfb749..9c8dab26f 100644 --- a/src/api/urls.py +++ b/src/api/urls.py @@ -36,7 +36,7 @@ urlpatterns = [ url(r'^blog/$', piwik_track_view(views.BlogView.as_view())), - url(r'^pictures/$', include('picture.api.urls')), + url(r'^pictures/', include('picture.api.urls')), url(r'^', include('social.api.urls')), url(r'^', include('catalogue.api.urls')), ] diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index b2289f667..068bae899 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -205,12 +205,12 @@ class Book(models.Model): @permalink def get_absolute_url(self): - return 'catalogue.views.book_detail', [self.slug] + return 'book_detail', [self.slug] @staticmethod @permalink def create_url(slug): - return 'catalogue.views.book_detail', [slug] + return 'book_detail', [slug] def gallery_path(self): return gallery_path(self.slug) diff --git a/src/catalogue/models/collection.py b/src/catalogue/models/collection.py index e95204341..b765abefe 100644 --- a/src/catalogue/models/collection.py +++ b/src/catalogue/models/collection.py @@ -40,7 +40,6 @@ class Collection(models.Model): def get_query(self): slugs = self.book_slugs.split() # allow URIs - # WTF slugs = [slug.rstrip('/').rsplit('/', 1)[-1] if '/' in slug else slug for slug in slugs] return models.Q(slug__in=slugs) diff --git a/src/catalogue/urls.py b/src/catalogue/urls.py index 50a4a4af9..8b37e0774 100644 --- a/src/catalogue/urls.py +++ b/src/catalogue/urls.py @@ -2,54 +2,47 @@ # 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 patterns, url +from django.conf.urls import url from django.db.models import Max from django.views.generic import ListView, RedirectView from catalogue.feeds import AudiobookFeed -from catalogue.views import CustomPDFFormView from catalogue.models import Book +from catalogue import views +import picture.views SLUG = r'[a-z0-9-]*' -urlpatterns = patterns( - 'picture.views', - - url(r'^obraz/strona/$', 'picture_page', name='picture_page'), +urlpatterns = [ + url(r'^obraz/strona/$', picture.views.picture_page, name='picture_page'), # pictures - currently pictures are coupled with catalogue, hence the url is here - url(r'^obraz/$', 'picture_list_thumb', name='picture_list_thumb'), - url(r'^obraz/(?P%s).html$' % SLUG, 'picture_viewer', name='picture_viewer'), - url(r'^obraz/(?P%s)/$' % SLUG, 'picture_detail'), + url(r'^obraz/$', picture.views.picture_list_thumb, name='picture_list_thumb'), + url(r'^obraz/(?P%s).html$' % SLUG, picture.views.picture_viewer, name='picture_viewer'), + url(r'^obraz/(?P%s)/$' % SLUG, picture.views.picture_detail), - url(r'^p/(?P\d+)/mini\.(?P.+)\.html', 'picture_mini', name='picture_mini'), - url(r'^p/(?P\d+)/short\.(?P.+)\.html', 'picture_short', name='picture_short'), - url(r'^pa/(?P\d+)/short\.(?P.+)\.html', 'picturearea_short', name='picture_area_short'), -) + url(r'^p/(?P\d+)/mini\.(?P.+)\.html', picture.views.picture_mini, name='picture_mini'), + url(r'^p/(?P\d+)/short\.(?P.+)\.html', picture.views.picture_short, name='picture_short'), + url(r'^pa/(?P\d+)/short\.(?P.+)\.html', picture.views.picturearea_short, name='picture_area_short'), -urlpatterns += patterns( - '', # old search page - redirected url(r'^szukaj/$', RedirectView.as_view( url='/szukaj/', query_string=True, permanent=True)), -) -urlpatterns += patterns( - 'catalogue.views', - url(r'^$', 'catalogue', name='catalogue'), + url(r'^$', views.catalogue, name='catalogue'), - url(r'^autor/$', 'tag_catalogue', {'category': 'author'}, name='author_catalogue'), - url(r'^epoka/$', 'tag_catalogue', {'category': 'epoch'}, name='epoch_catalogue'), - url(r'^gatunek/$', 'tag_catalogue', {'category': 'genre'}, name='genre_catalogue'), - url(r'^rodzaj/$', 'tag_catalogue', {'category': 'kind'}, name='kind_catalogue'), - url(r'^motyw/$', 'tag_catalogue', {'category': 'theme'}, name='theme_catalogue'), + url(r'^autor/$', views.tag_catalogue, {'category': 'author'}, name='author_catalogue'), + url(r'^epoka/$', views.tag_catalogue, {'category': 'epoch'}, name='epoch_catalogue'), + url(r'^gatunek/$', views.tag_catalogue, {'category': 'genre'}, name='genre_catalogue'), + url(r'^rodzaj/$', views.tag_catalogue, {'category': 'kind'}, name='kind_catalogue'), + url(r'^motyw/$', views.tag_catalogue, {'category': 'theme'}, name='theme_catalogue'), - url(r'^galeria/$', 'gallery', name='gallery'), - url(r'^kolekcje/$', 'collections', name='catalogue_collections'), + url(r'^galeria/$', views.gallery, name='gallery'), + url(r'^kolekcje/$', views.collections, name='catalogue_collections'), - url(r'^lektury/$', 'literature', name='book_list'), - url(r'^lektury/(?P[a-zA-Z0-9-]+)/$', 'collection', name='collection'), - url(r'^audiobooki/$', 'audiobooks', name='audiobook_list'), - url(r'^daisy/$', 'daisy_list', name='daisy_list'), + url(r'^lektury/$', views.literature, name='book_list'), + url(r'^lektury/(?P[a-zA-Z0-9-]+)/$', views.collection, name='collection'), + url(r'^audiobooki/$', views.audiobooks, name='audiobook_list'), + url(r'^daisy/$', views.daisy_list, name='daisy_list'), url(r'^nowe/$', ListView.as_view( queryset=Book.objects.filter(parent=None).order_by('-created_at'), template_name='catalogue/recent_list.html'), name='recent_list'), @@ -60,45 +53,45 @@ urlpatterns += patterns( queryset=Book.objects.filter(media__type='daisy').annotate(m=Max('media__uploaded_at')).order_by('-m'), template_name='catalogue/recent_daisy_list.html'), name='recent_daisy_list'), - url(r'^custompdf/(?P%s)/$' % SLUG, CustomPDFFormView(), name='custom_pdf_form'), + url(r'^custompdf/(?P%s)/$' % SLUG, views.CustomPDFFormView(), name='custom_pdf_form'), url(r'^audiobooki/(?Pmp3|ogg|daisy|all).xml$', AudiobookFeed(), name='audiobook_feed'), - url(r'^pobierz/(?P%s).(?P[a-z0-9]*)$' % SLUG, 'embargo_link', name='embargo_link'), + url(r'^pobierz/(?P%s).(?P[a-z0-9]*)$' % SLUG, views.embargo_link, name='embargo_link'), # zip - url(r'^zip/pdf\.zip$', 'download_zip', {'format': 'pdf', 'slug': None}, 'download_zip_pdf'), - url(r'^zip/epub\.zip$', 'download_zip', {'format': 'epub', 'slug': None}, 'download_zip_epub'), - url(r'^zip/mobi\.zip$', 'download_zip', {'format': 'mobi', 'slug': None}, 'download_zip_mobi'), - url(r'^zip/mp3/(?P%s)\.zip' % SLUG, 'download_zip', {'format': 'mp3'}, 'download_zip_mp3'), - url(r'^zip/ogg/(?P%s)\.zip' % SLUG, 'download_zip', {'format': 'ogg'}, 'download_zip_ogg'), + url(r'^zip/pdf\.zip$', views.download_zip, {'format': 'pdf', 'slug': None}, 'download_zip_pdf'), + url(r'^zip/epub\.zip$', views.download_zip, {'format': 'epub', 'slug': None}, 'download_zip_epub'), + url(r'^zip/mobi\.zip$', views.download_zip, {'format': 'mobi', 'slug': None}, 'download_zip_mobi'), + url(r'^zip/mp3/(?P%s)\.zip' % SLUG, views.download_zip, {'format': 'mp3'}, 'download_zip_mp3'), + url(r'^zip/ogg/(?P%s)\.zip' % SLUG, views.download_zip, {'format': 'ogg'}, 'download_zip_ogg'), # Public interface. Do not change this URLs. - url(r'^lektura/(?P%s)\.html$' % SLUG, 'book_text', name='book_text'), - url(r'^lektura/(?P%s)/audiobook/$' % SLUG, 'player', name='book_player'), - url(r'^lektura/(?P%s)/$' % SLUG, 'book_detail', name='book_detail'), + url(r'^lektura/(?P%s)\.html$' % SLUG, views.book_text, name='book_text'), + url(r'^lektura/(?P%s)/audiobook/$' % SLUG, views.player, name='book_player'), + url(r'^lektura/(?P%s)/$' % SLUG, views.book_detail, name='book_detail'), url(r'^lektura/(?P%s)/motyw/(?P[a-zA-Z0-9-]+)/$' % SLUG, - 'book_fragments', name='book_fragments'), + views.book_fragments, name='book_fragments'), - url(r'^okladka-ridero/(?P%s).png$' % SLUG, 'ridero_cover'), - url(r'^isbn/(?P(pdf|epub|mobi|txt|html))/(?P%s)/' % SLUG, 'get_isbn'), + url(r'^okladka-ridero/(?P%s).png$' % SLUG, views.ridero_cover), + url(r'^isbn/(?P(pdf|epub|mobi|txt|html))/(?P%s)/' % SLUG, views.get_isbn), # Includes. - url(r'^b/(?P\d+)/mini\.(?P.+)\.html', 'book_mini', name='catalogue_book_mini'), - url(r'^b/(?P\d+)/mini_nolink\.(?P.+)\.html', 'book_mini', {'with_link': False}, + url(r'^b/(?P\d+)/mini\.(?P.+)\.html', views.book_mini, name='catalogue_book_mini'), + url(r'^b/(?P\d+)/mini_nolink\.(?P.+)\.html', views.book_mini, {'with_link': False}, name='catalogue_book_mini_nolink'), - url(r'^b/(?P\d+)/short\.(?P.+)\.html', 'book_short', name='catalogue_book_short'), - url(r'^b/(?P\d+)/wide\.(?P.+)\.html', 'book_wide', name='catalogue_book_wide'), - url(r'^f/(?P\d+)/promo\.(?P.+)\.html', 'fragment_promo', name='catalogue_fragment_promo'), - url(r'^f/(?P\d+)/short\.(?P.+)\.html', 'fragment_short', name='catalogue_fragment_short'), - url(r'^t/(?P\d+)/box\.(?P.+)\.html', 'tag_box', name='catalogue_tag_box'), - url(r'^c/(?P.+)/box\.(?P.+)\.html', 'collection_box', name='catalogue_collection_box'), + url(r'^b/(?P\d+)/short\.(?P.+)\.html', views.book_short, name='catalogue_book_short'), + url(r'^b/(?P\d+)/wide\.(?P.+)\.html', views.book_wide, name='catalogue_book_wide'), + url(r'^f/(?P\d+)/promo\.(?P.+)\.html', views.fragment_promo, name='catalogue_fragment_promo'), + url(r'^f/(?P\d+)/short\.(?P.+)\.html', views.fragment_short, name='catalogue_fragment_short'), + url(r'^t/(?P\d+)/box\.(?P.+)\.html', views.tag_box, name='catalogue_tag_box'), + url(r'^c/(?P.+)/box\.(?P.+)\.html', views.collection_box, name='catalogue_collection_box'), # This should be the last pattern. - url(r'^galeria/(?P[a-zA-Z0-9-/]*)/$', 'tagged_object_list', {'list_type': 'gallery'}, + url(r'^galeria/(?P[a-zA-Z0-9-/]*)/$', views.tagged_object_list, {'list_type': 'gallery'}, name='tagged_object_list_gallery'), - url(r'^audiobooki/(?P[a-zA-Z0-9-/]*)/$', 'tagged_object_list', {'list_type': 'audiobooks'}, + url(r'^audiobooki/(?P[a-zA-Z0-9-/]*)/$', views.tagged_object_list, {'list_type': 'audiobooks'}, name='tagged_object_list_audiobooks'), - url(r'^(?P[a-zA-Z0-9-/]*)/$', 'tagged_object_list', {'list_type': 'books'}, + url(r'^(?P[a-zA-Z0-9-/]*)/$', views.tagged_object_list, {'list_type': 'books'}, name='tagged_object_list'), -) +] diff --git a/src/catalogue/views.py b/src/catalogue/views.py index f6d6cd5eb..2e43bd081 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -52,7 +52,6 @@ def book_list(request, filters=None, template_name='catalogue/book_list.html', for tag in books_by_author: if books_by_author[tag]: books_nav.setdefault(tag.sort_key[0], []).append(tag) - # WTF: dlaczego nie include? return render_to_response(template_name, { 'rendered_nav': render_to_string(nav_template_name, {'books_nav': books_nav}), 'rendered_book_list': render_to_string(list_template_name, { diff --git a/src/chunks/urls.py b/src/chunks/urls.py index 89472f961..0536a18b9 100644 --- a/src/chunks/urls.py +++ b/src/chunks/urls.py @@ -2,9 +2,10 @@ # 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 patterns, url +from django.conf.urls import url +from . import views -urlpatterns = patterns( - 'chunks.views', - url(r'^chunk/(?P.+)\.(?P.+)\.html$', 'chunk', name='chunk'), -) + +urlpatterns = [ + url(r'^chunk/(?P.+)\.(?P.+)\.html$', views.chunk, name='chunk'), +] diff --git a/src/contact/admin.py b/src/contact/admin.py index af14c6b02..41095092e 100644 --- a/src/contact/admin.py +++ b/src/contact/admin.py @@ -5,7 +5,7 @@ import json from django.contrib import admin from django.utils.translation import ugettext as _ from django.utils.safestring import mark_safe -from django.conf.urls import patterns, url +from django.conf.urls import url from django.http import HttpResponse, Http404 from wolnelektury.utils import UnicodeCSVWriter @@ -104,12 +104,10 @@ class ContactAdmin(admin.ModelAdmin): return super(ContactAdmin, self).changelist_view(request, extra_context=context) def get_urls(self): - # urls = super(ContactAdmin, self).get_urls() - return patterns( - '', + return [ url(r'^extract/(?P[\w-]+)/(?P[\w-]+)/$', self.admin_site.admin_view(extract_view), name='contact_extract') - ) + super(ContactAdmin, self).get_urls() + ] + super(ContactAdmin, self).get_urls() def extract_view(request, form_tag, extract_type_slug): diff --git a/src/contact/urls.py b/src/contact/urls.py index f2ef9444e..c475cd429 100644 --- a/src/contact/urls.py +++ b/src/contact/urls.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -from django.conf.urls import patterns, url +from django.conf.urls import url from . import views -urlpatterns = patterns( - 'contact.views', + +urlpatterns = [ url(r'^(?P[^/]+)/$', views.form, name='contact_form'), url(r'^(?P[^/]+)/thanks/$', views.thanks, name='contact_thanks'), url(r'^attachment/(?P\d+)/(?P[^/]+)/$', views.attachment, name='contact_attachment'), url(r'^results/(?P\d+)/(?P[0-9a-f]+)/', views.results, name='contact_results'), -) +] diff --git a/src/dictionary/urls.py b/src/dictionary/urls.py index 6df9a4785..a5582a17a 100755 --- a/src/dictionary/urls.py +++ b/src/dictionary/urls.py @@ -2,10 +2,9 @@ # 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 patterns, url +from django.conf.urls import url from dictionary.views import NotesView -urlpatterns = patterns( - 'dictionary.views', +urlpatterns = [ url(r'^$', NotesView.as_view(), name='dictionary_notes'), -) +] diff --git a/src/funding/urls.py b/src/funding/urls.py index 1f0d494eb..f8afc66bb 100644 --- a/src/funding/urls.py +++ b/src/funding/urls.py @@ -2,33 +2,30 @@ # 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 patterns, url, include +from django.conf.urls import url, include +from . import views -from .views import WLFundView, OfferDetailView, OfferListView, ThanksView, NoThanksView, CurrentView, \ - DisableNotifications +urlpatterns = [ + url(r'^$', views.CurrentView.as_view(), name='funding_current'), + url(r'^teraz/$', views.CurrentView.as_view()), + url(r'^teraz/(?P[^/]+)/$', views.CurrentView.as_view(), name='funding_current'), + url(r'^lektura/$', views.OfferListView.as_view(), name='funding'), + url(r'^lektura/(?P[^/]+)/$', views.OfferDetailView.as_view(), name='funding_offer'), + url(r'^pozostale/$', views.WLFundView.as_view(), name='funding_wlfund'), -urlpatterns = patterns( - 'funding.views', - url(r'^$', CurrentView.as_view(), name='funding_current'), - url(r'^teraz/$', CurrentView.as_view()), - url(r'^teraz/(?P[^/]+)/$', CurrentView.as_view(), name='funding_current'), - url(r'^lektura/$', OfferListView.as_view(), name='funding'), - url(r'^lektura/(?P[^/]+)/$', OfferDetailView.as_view(), name='funding_offer'), - url(r'^pozostale/$', WLFundView.as_view(), name='funding_wlfund'), + url(r'^dziekujemy/$', views.ThanksView.as_view(), name='funding_thanks'), + url(r'^niepowodzenie/$', views.NoThanksView.as_view(), name='funding_nothanks'), - url(r'^dziekujemy/$', ThanksView.as_view(), name='funding_thanks'), - url(r'^niepowodzenie/$', NoThanksView.as_view(), name='funding_nothanks'), - - url(r'^wylacz_email/$', DisableNotifications.as_view(), name='funding_disable_notifications'), + url(r'^wylacz_email/$', views.DisableNotifications.as_view(), name='funding_disable_notifications'), url(r'^getpaid/', include('getpaid.urls')), # Includes - url(r'^o/(?P\d+)/top-bar\.(?P.+)\.html$', 'top_bar', name='funding_top_bar'), - url(r'^o/(?P\d+)/detail-bar\.(?P.+)\.html$', 'detail_bar', name='funding_detail_bar'), - url(r'^o/(?P\d+)/list-bar\.(?P.+)\.html$', 'list_bar', name='funding_list_bar'), - url(r'^o/(?P\d+)/status\.(?P.+)\.html$', 'offer_status', name='funding_status'), - url(r'^o/(?P\d+)/status-more\.(?P.+)\.html$', 'offer_status_more', name='funding_status_more'), - url(r'^o/(?P\d+)/fundings/(?P\d+)\.(?P.+)\.html$', 'offer_fundings', name='funding_fundings'), -) + url(r'^o/(?P\d+)/top-bar\.(?P.+)\.html$', views.top_bar, name='funding_top_bar'), + url(r'^o/(?P\d+)/detail-bar\.(?P.+)\.html$', views.detail_bar, name='funding_detail_bar'), + url(r'^o/(?P\d+)/list-bar\.(?P.+)\.html$', views.list_bar, name='funding_list_bar'), + url(r'^o/(?P\d+)/status\.(?P.+)\.html$', views.offer_status, name='funding_status'), + url(r'^o/(?P\d+)/status-more\.(?P.+)\.html$', views.offer_status_more, name='funding_status_more'), + url(r'^o/(?P\d+)/fundings/(?P\d+)\.(?P.+)\.html$', views.offer_fundings, name='funding_fundings'), +] diff --git a/src/funding/views.py b/src/funding/views.py index 18000c05d..74530a4af 100644 --- a/src/funding/views.py +++ b/src/funding/views.py @@ -88,7 +88,9 @@ class OfferDetailView(FormView): raise Http404 return super(OfferDetailView, self).dispatch(request, slug) - def get_form(self, form_class): + def get_form(self, form_class=None): + if form_class is None: + form_class = self.get_form_class() if self.request.method == 'POST': return form_class(self.object, self.request.POST) else: diff --git a/src/infopages/urls.py b/src/infopages/urls.py index 37025a1e4..ffae43966 100755 --- a/src/infopages/urls.py +++ b/src/infopages/urls.py @@ -2,10 +2,10 @@ # 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 patterns, url +from django.conf.urls import url +from . import views -urlpatterns = patterns( - 'infopages.views', - url(r'^(?P[a-zA-Z0-9_-]+)/$', 'infopage', name='infopage'), -) +urlpatterns = [ + url(r'^(?P[a-zA-Z0-9_-]+)/$', views.infopage, name='infopage'), +] diff --git a/src/lesmianator/urls.py b/src/lesmianator/urls.py index 37e363f8c..2685e83e2 100644 --- a/src/lesmianator/urls.py +++ b/src/lesmianator/urls.py @@ -2,13 +2,14 @@ # 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 url, patterns +from django.conf.urls import url +from . import views -urlpatterns = patterns( - 'lesmianator.views', - url(r'^$', 'main_page', name='lesmianator'), - url(r'^wiersz/$', 'new_poem', name='new_poem'), - url(r'^lektura/(?P[a-z0-9-]+)/$', 'poem_from_book', name='poem_from_book'), - url(r'^polka/(?P[a-zA-Z0-9-]+)/$', 'poem_from_set', name='poem_from_set'), - url(r'^wiersz/(?P[a-zA-Z0-9-]+)/$', 'get_poem', name='get_poem'), -) + +urlpatterns = [ + url(r'^$', views.main_page, name='lesmianator'), + url(r'^wiersz/$', views.new_poem, name='new_poem'), + url(r'^lektura/(?P[a-z0-9-]+)/$', views.poem_from_book, name='poem_from_book'), + url(r'^polka/(?P[a-zA-Z0-9-]+)/$', views.poem_from_set, name='poem_from_set'), + url(r'^wiersz/(?P[a-zA-Z0-9-]+)/$', views.get_poem, name='get_poem'), +] diff --git a/src/libraries/urls.py b/src/libraries/urls.py index ae1635948..897da151f 100644 --- a/src/libraries/urls.py +++ b/src/libraries/urls.py @@ -2,12 +2,12 @@ # 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 patterns, url +from django.conf.urls import url +from . import views -urlpatterns = patterns( - 'libraries.views', - url(r'^$', 'main_view', name='libraries_main_view'), - url(r'^(?P[a-zA-Z0-9_-]+)$', 'catalog_view', name='libraries_catalog_view'), - url(r'^(?P[a-zA-Z0-9_-]+)/(?P[a-zA-Z0-9_-]+)$', 'library_view', name='libraries_library_view'), -) +urlpatterns = [ + url(r'^$', views.main_view, name='libraries_main_view'), + url(r'^(?P[a-zA-Z0-9_-]+)$', views.catalog_view, name='libraries_catalog_view'), + url(r'^(?P[a-zA-Z0-9_-]+)/(?P[a-zA-Z0-9_-]+)$', views.library_view, name='libraries_library_view'), +] diff --git a/src/oai/handlers.py b/src/oai/handlers.py index 6fbcd4271..0eeea8c0d 100644 --- a/src/oai/handlers.py +++ b/src/oai/handlers.py @@ -56,7 +56,6 @@ def nsdcterms(name): return '{%s}%s' % (NS_DCTERMS, name) -# WTF class Catalogue(common.ResumptionOAIPMH): TAG_CATEGORIES = ['author', 'epoch', 'kind', 'genre'] diff --git a/src/oai/urls.py b/src/oai/urls.py index 13ea9f12a..205d5e6c9 100644 --- a/src/oai/urls.py +++ b/src/oai/urls.py @@ -2,7 +2,10 @@ # 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 patterns, url +from django.conf.urls import url +from . import views -urlpatterns = patterns('oai.views', - url(r'^$', 'oaipmh', name='oaipmh')) + +urlpatterns = [ + url(r'^$', views.oaipmh, name='oaipmh') +] diff --git a/src/opds/urls.py b/src/opds/urls.py index edf928297..8f1059f1e 100644 --- a/src/opds/urls.py +++ b/src/opds/urls.py @@ -2,16 +2,15 @@ # 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 patterns, url +from django.conf.urls import url from opds.views import RootFeed, ByCategoryFeed, ByTagFeed, UserFeed, UserSetFeed, SearchFeed -urlpatterns = patterns( - 'opds.views', +urlpatterns = [ url(r'^$', RootFeed(), name="opds_authors"), url(r'^search/$', SearchFeed(), name="opds_search"), url(r'^user/$', UserFeed(), name="opds_user"), url(r'^set/(?P[a-zA-Z0-9-]+)/$', UserSetFeed(), name="opds_user_set"), url(r'^(?P[a-zA-Z0-9-]+)/$', ByCategoryFeed(), name="opds_by_category"), url(r'^(?P[a-zA-Z0-9-]+)/(?P[a-zA-Z0-9-]+)/$', ByTagFeed(), name="opds_by_tag"), -) +] diff --git a/src/paypal/tests.py b/src/paypal/tests.py index e38fd8476..a7badbe83 100644 --- a/src/paypal/tests.py +++ b/src/paypal/tests.py @@ -167,11 +167,15 @@ class PaypalTests(WLTestCase): self.client.login(username='test', password='test') BillingPlan.objects.create(amount=100) response = self.client.get('/paypal/app-return/?token=secret-token') - self.assertRedirects(response, 'wolnelekturyapp://paypal_return') + self.assertRedirects( + response, 'wolnelekturyapp://paypal_return', + fetch_redirect_response=False) # Repeated returns will not generate further agreements. response = self.client.get('/paypal/app-return/?token=secret-token') - self.assertRedirects(response, 'wolnelekturyapp://paypal_return') + self.assertRedirects( + response, 'wolnelekturyapp://paypal_return', + fetch_redirect_response=False) self.assertEqual(BillingAgreement.objects.all().count(), 1) self.assertTrue(user_is_subscribed(self.user)) @@ -185,7 +189,9 @@ class PaypalTests(WLTestCase): execute=Mock(return_value=Mock(id=None)))): self.client.get('/paypal/app-return/?token=secret-token') response = self.client.get('/paypal/app-return/?token=secret-token') - self.assertRedirects(response, 'wolnelekturyapp://paypal_error') + self.assertRedirects( + response, 'wolnelekturyapp://paypal_error', + fetch_redirect_response=False) # No agreement created in our DB if not executed successfully. self.assertEqual(BillingAgreement.objects.all().count(), 0) @@ -195,7 +201,9 @@ class PaypalTests(WLTestCase): execute=BillingAgreementMock.execute, find=Mock(side_effect=ResourceNotFound(None)))): response = self.client.get('/paypal/app-return/?token=secret-token') - self.assertRedirects(response, 'wolnelekturyapp://paypal_return') + self.assertRedirects( + response, 'wolnelekturyapp://paypal_return', + fetch_redirect_response=False) # Now the agreement exists in our DB, but is not active. self.assertEqual([b.active for b in BillingAgreement.objects.all()], [False]) diff --git a/src/picture/models.py b/src/picture/models.py index 643149a1a..e20325702 100644 --- a/src/picture/models.py +++ b/src/picture/models.py @@ -9,7 +9,6 @@ from sorl.thumbnail import ImageField from django.conf import settings from django.contrib.contenttypes.fields import GenericRelation from django.core.files.storage import FileSystemStorage -from django.utils.datastructures import SortedDict from slugify import slugify from ssify import flush_ssi_includes @@ -326,33 +325,6 @@ class Picture(models.Model): annotated.paste(annotation.resize((img.size[0], 40), Image.ANTIALIAS), (0, img.size[1])) return annotated - # WTF/unused - @classmethod - def picture_list(cls, filter=None): - """Generates a hierarchical listing of all pictures - Pictures are optionally filtered with a test function. - """ - - pics = cls.objects.all().order_by('sort_key').only('title', 'slug', 'image_file') - - if filter: - pics = pics.filter(filter).distinct() - - pics_by_author = SortedDict() - orphans = [] - for tag in catalogue.models.Tag.objects.filter(category='author'): - pics_by_author[tag] = [] - - for pic in pics.iterator(): - authors = list(pic.authors().only('pk')) - if authors: - for author in authors: - pics_by_author[author].append(pic) - else: - orphans.append(pic) - - return pics_by_author, orphans - @property def info(self): if not hasattr(self, '_info'): diff --git a/src/picture/views.py b/src/picture/views.py index 6ace13427..6f02007e0 100644 --- a/src/picture/views.py +++ b/src/picture/views.py @@ -10,23 +10,6 @@ from picture.models import Picture, PictureArea from catalogue.utils import split_tags from ssify import ssi_included from sponsors.models import Sponsor - - -# WTF/unused -# # was picture/picture_list.html list (without thumbs) -# def picture_list(request, filter=None, get_filter=None, template_name='catalogue/picture_list.html', -# cache_key=None, context=None): -# """ generates a listing of all books, optionally filtered with a test function """ -# -# if get_filter: -# filt = get_filter() -# pictures_by_author, orphans = Picture.picture_list(filt) -# books_nav = OrderedDict() -# for tag in pictures_by_author: -# if pictures_by_author[tag]: -# books_nav.setdefault(tag.sort_key[0], []).append(tag) -# -# return render_to_response(template_name, locals(), context_instance=RequestContext(request)) from wolnelektury.utils import ajax @@ -45,10 +28,6 @@ def picture_detail(request, slug): theme_things = split_tags(picture.related_themes()) - # categories = SortedDict() - # for tag in picture.tags.iterator(): - # categories.setdefault(tag.category, []).append(tag) - return render_to_response("picture/picture_detail.html", { 'picture': picture, 'themes': theme_things.get('theme', []), diff --git a/src/polls/urls.py b/src/polls/urls.py index 0bec684e5..8a5f62136 100644 --- a/src/polls/urls.py +++ b/src/polls/urls.py @@ -2,10 +2,10 @@ # 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 patterns, url +from django.conf.urls import url +from . import views -urlpatterns = patterns( - 'polls.views', - url(r'^(?P[^/]+)$', 'poll', name='poll'), -) +urlpatterns = [ + url(r'^(?P[^/]+)$', views.poll, name='poll'), +] diff --git a/src/push/urls.py b/src/push/urls.py index 70a8487be..173b2dd18 100644 --- a/src/push/urls.py +++ b/src/push/urls.py @@ -2,11 +2,11 @@ # 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 patterns, url - +from django.conf.urls import url from push import views -urlpatterns = ( + +urlpatterns = [ url(r'^wyslij/$', views.notification_form, name='notification_form'), url(r'^wyslane/$', views.notification_sent, name='notification_sent'), -) +] diff --git a/src/reporting/urls.py b/src/reporting/urls.py index 3b09f1152..f4a65f44b 100755 --- a/src/reporting/urls.py +++ b/src/reporting/urls.py @@ -2,12 +2,12 @@ # 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 patterns, url +from django.conf.urls import url +from . import views -urlpatterns = patterns( - 'reporting.views', - url(r'^$', 'stats_page', name='reporting_stats'), - url(r'^katalog.pdf$', 'catalogue_pdf', name='reporting_catalogue_pdf'), - url(r'^katalog.csv$', 'catalogue_csv', name='reporting_catalogue_csv'), -) +urlpatterns = [ + url(r'^$', views.stats_page, name='reporting_stats'), + url(r'^katalog.pdf$', views.catalogue_pdf, name='reporting_catalogue_pdf'), + url(r'^katalog.csv$', views.catalogue_csv, name='reporting_catalogue_csv'), +] diff --git a/src/search/urls.py b/src/search/urls.py index 5a59422b5..46914d6d2 100644 --- a/src/search/urls.py +++ b/src/search/urls.py @@ -2,10 +2,11 @@ # 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 patterns, url +from django.conf.urls import url +from . import views -urlpatterns = patterns( - 'search.views', - url(r'^$', 'main', name='wlsearch'), - url(r'^hint/$', 'hint', name='search_hint'), -) + +urlpatterns = [ + url(r'^$', views.main, name='wlsearch'), + url(r'^hint/$', views.hint, name='search_hint'), +] diff --git a/src/social/urls.py b/src/social/urls.py index f9222ce93..395e54ac1 100755 --- a/src/social/urls.py +++ b/src/social/urls.py @@ -2,26 +2,19 @@ # 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 patterns, url +from django.conf.urls import url from django.views.decorators.cache import never_cache -from social.views import ObjectSetsFormView +from . import views -urlpatterns = patterns( - 'social.views', - url(r'^lektura/(?P[a-z0-9-]+)/lubie/$', 'like_book', name='social_like_book'), - url(r'^lektura/(?P[a-z0-9-]+)/nie_lubie/$', 'unlike_book', name='social_unlike_book'), - url(r'^lektura/(?P[a-z0-9-]+)/polki/$', never_cache(ObjectSetsFormView()), name='social_book_sets'), - url(r'^polka/$', 'my_shelf', name='social_my_shelf'), - # Includes - url(r'^cite/(?P\d+)\.(?P.+)\.html$', 'cite', name='social_cite'), - url(r'^cite_main/(?P\d+)\.(?P.+)\.html$', 'cite', {'main': True}, name='social_cite_main'), - url(r'^cite_info/(?P\d+).html$', 'cite_info', name='social_cite_info'), +urlpatterns = [ + url(r'^lektura/(?P[a-z0-9-]+)/lubie/$', views.like_book, name='social_like_book'), + url(r'^lektura/(?P[a-z0-9-]+)/nie_lubie/$', views.unlike_book, name='social_unlike_book'), + url(r'^lektura/(?P[a-z0-9-]+)/polki/$', never_cache(views.ObjectSetsFormView()), name='social_book_sets'), + url(r'^polka/$', views.my_shelf, name='social_my_shelf'), - # url(r'^polki/(?P[a-zA-Z0-9-]+)/formaty/$', 'shelf_book_formats', name='shelf_book_formats'), - # url(r'^polki/(?P[a-zA-Z0-9-]+)/(?P%s)/usun$' % SLUG, 'remove_from_shelf', name='remove_from_shelf'), - # url(r'^polki/$', 'user_shelves', name='user_shelves'), - # url(r'^polki/(?P[a-zA-Z0-9-]+)/usun/$', 'delete_shelf', name='delete_shelf'), - # url(r'^polki/(?P[a-zA-Z0-9-]+)\.zip$', 'download_shelf', name='download_shelf'), - # url(r'^polki/nowa/$', 'new_set', name='new_set'), -) + # Includes + url(r'^cite/(?P\d+)\.(?P.+)\.html$', views.cite, name='social_cite'), + url(r'^cite_main/(?P\d+)\.(?P.+)\.html$', views.cite, {'main': True}, name='social_cite_main'), + url(r'^cite_info/(?P\d+).html$', views.cite_info, name='social_cite_info'), +] diff --git a/src/sponsors/urls.py b/src/sponsors/urls.py index 7c6bc2ce6..fe3898678 100644 --- a/src/sponsors/urls.py +++ b/src/sponsors/urls.py @@ -2,9 +2,10 @@ # 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 patterns, url +from django.conf.urls import url +from . import views -urlpatterns = patterns( - 'sponsors.views', - url(r'^page/(?P.+)\.html$', 'page', name='sponsor_page'), -) + +urlpatterns = [ + url(r'^page/(?P.+)\.html$', views.page, name='sponsor_page'), +] diff --git a/src/suggest/urls.py b/src/suggest/urls.py index 5e721d45e..167a1a82f 100644 --- a/src/suggest/urls.py +++ b/src/suggest/urls.py @@ -2,11 +2,10 @@ # 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 patterns, url +from django.conf.urls import url from suggest import views -urlpatterns = patterns( - '', +urlpatterns = [ url(r'^$', views.SuggestionFormView(), name='suggest'), url(r'^plan/$', views.PublishingSuggestionFormView(), name='suggest_publishing'), -) +] diff --git a/src/waiter/urls.py b/src/waiter/urls.py index 69ab03a85..51d5f6e95 100644 --- a/src/waiter/urls.py +++ b/src/waiter/urls.py @@ -2,9 +2,9 @@ # 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 patterns, url +from django.conf.urls import url +from waiter import views -urlpatterns = patterns( - 'waiter.views', - url(r'^(?P.*)$', 'wait', name='waiter'), -) +urlpatterns = [ + url(r'^(?P.*)$', views.wait, name='waiter'), +] diff --git a/src/wolnelektury/settings/apps.py b/src/wolnelektury/settings/apps.py index 2c76f67ed..c98944b39 100644 --- a/src/wolnelektury/settings/apps.py +++ b/src/wolnelektury/settings/apps.py @@ -68,7 +68,6 @@ INSTALLED_APPS_CONTRIB = [ 'django_gravatar', # allauth stuff - 'uni_form', 'allauth', 'allauth.account', 'allauth.socialaccount', diff --git a/src/wolnelektury/settings/basic.py b/src/wolnelektury/settings/basic.py index 7990f2535..ebadbb8e0 100644 --- a/src/wolnelektury/settings/basic.py +++ b/src/wolnelektury/settings/basic.py @@ -49,10 +49,10 @@ TEMPLATES = [{ ), 'context_processors': ( 'django.contrib.auth.context_processors.auth', - 'django.core.context_processors.debug', - 'django.core.context_processors.i18n', - 'django.core.context_processors.media', - 'django.core.context_processors.request', + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.request', 'wolnelektury.context_processors.extra_settings', 'search.context_processors.search_form', ), diff --git a/src/wolnelektury/settings/static.py b/src/wolnelektury/settings/static.py index 3c1997d59..146e35bae 100644 --- a/src/wolnelektury/settings/static.py +++ b/src/wolnelektury/settings/static.py @@ -33,9 +33,6 @@ PIPELINE = { 'css/annoy.css', - 'uni_form/uni-form.css', - 'uni_form/default.uni-form.css', - 'css/ui-lightness/jquery-ui-1.8.16.custom.css', 'css/tlite.css', @@ -112,8 +109,6 @@ PIPELINE = { 'js/search.js', 'funding/funding.js', - 'uni_form/uni-form.js', - 'js/annoy.js', ), 'output_filename': 'js/base.min.js', diff --git a/src/wolnelektury/templates/base/superbase.html b/src/wolnelektury/templates/base/superbase.html index f5feb4ed7..12a6565ea 100644 --- a/src/wolnelektury/templates/base/superbase.html +++ b/src/wolnelektury/templates/base/superbase.html @@ -68,7 +68,7 @@
{% for lang in LANGUAGES %} -
+ {% ssi_csrf_token %} -
- {% endblock %} diff --git a/src/wolnelektury/templates/socialaccount/connections.html b/src/wolnelektury/templates/socialaccount/connections.html index 0f107242a..681038601 100644 --- a/src/wolnelektury/templates/socialaccount/connections.html +++ b/src/wolnelektury/templates/socialaccount/connections.html @@ -13,31 +13,25 @@

{% blocktrans %}You can sign in to your account using any of the following third party accounts:{% endblocktrans %}

-
+ {% csrf_token %} -
{% if form.non_field_errors %} -
{{form.non_field_errors}}
+
{{form.non_field_errors}}
{% endif %} {% for base_account in form.accounts %} {% with base_account.get_provider_account as account %} -
-
+

{% endwith %} {% endfor %} -
-
-
-- 2.20.1