From 4fae06ea1b9fec1a45482ac043aa049ebce3f465 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 25 Jul 2022 12:05:52 +0200 Subject: [PATCH 1/1] Update for Django 4. --- requirements/requirements.txt | 24 ++++----- src/apiclient/urls.py | 10 ++-- src/cover/forms.py | 12 ++--- src/cover/models.py | 2 +- src/cover/urls.py | 17 +++--- src/documents/forms.py | 2 +- src/documents/models/book.py | 2 +- src/documents/models/chunk.py | 2 +- src/documents/models/image.py | 2 +- src/documents/models/project.py | 2 +- src/documents/models/publish_log.py | 2 +- src/documents/templatetags/book_list.py | 2 +- src/documents/templatetags/documents.py | 2 +- src/documents/templatetags/wall.py | 2 +- src/documents/urls.py | 70 ++++++++++++------------- src/documents/views.py | 5 +- src/dvcs/models.py | 2 +- src/dvcs/signals.py | 2 +- src/email_mangler/templatetags/email.py | 2 +- src/redakcja/urls.py | 31 ++++++----- src/toolbar/admin.py | 2 +- src/toolbar/models.py | 2 +- src/wiki/forms.py | 2 +- src/wiki/models.py | 2 +- src/wiki/urls.py | 48 +++++++---------- src/wiki/views.py | 2 +- src/wiki_img/forms.py | 2 +- src/wiki_img/urls.py | 16 +++--- src/wiki_img/views.py | 2 +- 29 files changed, 129 insertions(+), 144 deletions(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 5341b624..2f146c98 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -7,25 +7,25 @@ Pillow oauth2 httplib2 # oauth2 dependency python-slugify -python-docx==0.8.10 +python-docx==0.8.11 Wikidata==0.6.1 -librarian==2.4.7 +librarian==2.4.8 ## Django -Django==3.2.14 -fnpdjango==0.5 -django-pipeline==2.0.7 +Django==4.0.6 +fnpdjango==0.6 +django-pipeline==2.0.8 django-cas-ng==4.3.0 sorl-thumbnail==12.8.0 -fnp-django-pagination==2.2.4 +fnp-django-pagination==2.2.5 django-gravatar2==1.4.4 -django-extensions==3.1.3 -django-bootstrap4==3.0.1 +django-extensions==3.2.0 +django-bootstrap4==22.1 libsasscompiler==0.1.9 -django-debug-toolbar==3.2.4 -django-admin-numeric-filter==0.1.6 +django-debug-toolbar==3.5.0 +django-admin-numeric-filter @ git+https://github.com/lukasvinclav/django-admin-numeric-filter.git@83853dfcc8d354c7aea8020a075bbd83dc8ca171 djangorestframework==3.13.1 -django-filter==21.1 +django-filter==22.1 -sentry-sdk==0.12.2 +sentry-sdk==1.8.0 diff --git a/src/apiclient/urls.py b/src/apiclient/urls.py index 580a2c1b..f0613804 100644 --- a/src/apiclient/urls.py +++ b/src/apiclient/urls.py @@ -1,13 +1,13 @@ # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -from django.conf.urls import url +from django.urls import path from . import views urlpatterns = [ - url(r'^oauth/$', views.oauth, name='apiclient_oauth'), - url(r'^oauth_callback/$', views.oauth_callback, name='apiclient_oauth_callback'), - url(r'^oauth-beta/$', views.oauth, kwargs={'beta': True}, name='apiclient_beta_oauth'), - url(r'^oauth_callback-beta/$', views.oauth_callback, kwargs={'beta': True}, name='apiclient_beta_callback'), + path('oauth/', views.oauth, name='apiclient_oauth'), + path('oauth_callback/', views.oauth_callback, name='apiclient_oauth_callback'), + path('oauth-beta/', views.oauth, kwargs={'beta': True}, name='apiclient_beta_oauth'), + path('oauth_callback-beta/', views.oauth_callback, kwargs={'beta': True}, name='apiclient_beta_callback'), ] diff --git a/src/cover/forms.py b/src/cover/forms.py index ee82a5af..7a855940 100644 --- a/src/cover/forms.py +++ b/src/cover/forms.py @@ -5,7 +5,7 @@ from io import BytesIO from django import forms from django.conf import settings -from django.utils.translation import ugettext_lazy as _, ugettext +from django.utils.translation import gettext_lazy as _, gettext from cover.models import Image from django.utils.safestring import mark_safe from PIL import Image as PILImage @@ -36,7 +36,7 @@ class ImageAddForm(forms.ModelForm): pass else: raise forms.ValidationError(mark_safe( - ugettext('Image already in repository.') + gettext('Image already in repository.') % {'url': img.get_absolute_url()})) return cl @@ -46,7 +46,7 @@ class ImageAddForm(forms.ModelForm): same_source = Image.objects.filter(source_url=source_url) if same_source: raise forms.ValidationError(mark_safe( - ugettext('Image already in repository.') + gettext('Image already in repository.') % {'url': same_source.first().get_absolute_url()})) return source_url @@ -60,7 +60,7 @@ class ImageAddForm(forms.ModelForm): download_url = cleaned_data.get('download_url', None) uploaded_file = cleaned_data.get('file', None) if not download_url and not uploaded_file: - raise forms.ValidationError(ugettext('No image specified')) + raise forms.ValidationError(gettext('No image specified')) if download_url: image_data = URLOpener().open(download_url).read() width, height = PILImage.open(BytesIO(image_data)).size @@ -68,7 +68,7 @@ class ImageAddForm(forms.ModelForm): width, height = PILImage.open(uploaded_file.file).size min_width, min_height = settings.MIN_COVER_SIZE if width < min_width or height < min_height: - raise forms.ValidationError(ugettext('Image too small: %sx%s, minimal dimensions %sx%s') % + raise forms.ValidationError(gettext('Image too small: %sx%s, minimal dimensions %sx%s') % (width, height, min_width, min_height)) return cleaned_data @@ -85,7 +85,7 @@ class ImageEditForm(forms.ModelForm): width, height = PILImage.open(uploaded_file.file).size min_width, min_height = settings.MIN_COVER_SIZE if width < min_width or height < min_height: - raise forms.ValidationError(ugettext('Image too small: %sx%s, minimal dimensions %sx%s') % + raise forms.ValidationError(gettext('Image too small: %sx%s, minimal dimensions %sx%s') % (width, height, min_width, min_height)) diff --git a/src/cover/models.py b/src/cover/models.py index 33c5e738..04c2a6bc 100644 --- a/src/cover/models.py +++ b/src/cover/models.py @@ -8,7 +8,7 @@ from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver from django.urls import reverse -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.contrib.sites.models import Site from PIL import Image as PILImage from cover.utils import URLOpener diff --git a/src/cover/urls.py b/src/cover/urls.py index 82788351..20cd7d60 100644 --- a/src/cover/urls.py +++ b/src/cover/urls.py @@ -1,22 +1,21 @@ # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -from django.conf.urls import url from django.urls import path from . import views urlpatterns = [ - url(r'^preview/$', views.preview_from_xml, name='cover_preview'), - url(r'^preview/(?P[^/]+)/$', views.preview, name='cover_preview'), - url(r'^preview/(?P[^/]+)/(?P[^/]+)/$', + path('preview/', views.preview_from_xml, name='cover_preview'), + path('preview//', views.preview, name='cover_preview'), + path('preview///', views.preview, name='cover_preview'), - url(r'^preview/(?P[^/]+)/(?P[^/]+)/(?P\d+)/$', + path('preview////', views.preview, name='cover_preview'), - url(r'^image/$', views.image_list, name='cover_image_list'), - url(r'^image/(?P\d+)/?$', views.image, name='cover_image'), - url(r'^image/(?P\d+)/file/', views.image_file, name='cover_file'), - url(r'^add_image/$', views.add_image, name='cover_add_image'), + path('image/', views.image_list, name='cover_image_list'), + path('image//', views.image, name='cover_image'), + path('image//file/', views.image_file, name='cover_file'), + path('add_image/', views.add_image, name='cover_add_image'), path('quick-import//', views.quick_import, name='cover_quick_import'), ] diff --git a/src/documents/forms.py b/src/documents/forms.py index 418ae4ac..6598e75c 100644 --- a/src/documents/forms.py +++ b/src/documents/forms.py @@ -3,7 +3,7 @@ # from django.db.models import Count from django import forms -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.conf import settings from slugify import slugify from .constants import MASTERS diff --git a/src/documents/models/book.py b/src/documents/models/book.py index 1580f74a..23d3344b 100644 --- a/src/documents/models/book.py +++ b/src/documents/models/book.py @@ -6,7 +6,7 @@ from django.contrib.sites.models import Site from django.db import connection, models, transaction from django.template.loader import render_to_string from django.urls import reverse -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.conf import settings from slugify import slugify diff --git a/src/documents/models/chunk.py b/src/documents/models/chunk.py index 2698b58f..4d8f6d23 100644 --- a/src/documents/models/chunk.py +++ b/src/documents/models/chunk.py @@ -6,7 +6,7 @@ from django.db import models from django.db.utils import IntegrityError from django.template.loader import render_to_string from django.urls import reverse -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from documents.helpers import cached_in_field from documents.managers import VisibleManager from dvcs import models as dvcs_models diff --git a/src/documents/models/image.py b/src/documents/models/image.py index b05c9288..fd3d8c41 100644 --- a/src/documents/models/image.py +++ b/src/documents/models/image.py @@ -6,7 +6,7 @@ from django.contrib.sites.models import Site from django.db import models from django.template.loader import render_to_string from django.urls import reverse -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from documents.helpers import cached_in_field from documents.models import Project from dvcs import models as dvcs_models diff --git a/src/documents/models/project.py b/src/documents/models/project.py index f0ac752f..cc78ba58 100644 --- a/src/documents/models/project.py +++ b/src/documents/models/project.py @@ -2,7 +2,7 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class Project(models.Model): diff --git a/src/documents/models/publish_log.py b/src/documents/models/publish_log.py index 5322bb62..2073a954 100644 --- a/src/documents/models/publish_log.py +++ b/src/documents/models/publish_log.py @@ -3,7 +3,7 @@ # from django.contrib.auth.models import User from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from documents.models import Chunk, Image diff --git a/src/documents/templatetags/book_list.py b/src/documents/templatetags/book_list.py index 88120d20..2261f5d6 100644 --- a/src/documents/templatetags/book_list.py +++ b/src/documents/templatetags/book_list.py @@ -4,7 +4,7 @@ import re from django.db.models import Q, Count, F, Max from django import template -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.contrib.auth.models import User from documents.models import Book, Chunk, Image, Project diff --git a/src/documents/templatetags/documents.py b/src/documents/templatetags/documents.py index 5c3b1eb8..b0a34bc9 100644 --- a/src/documents/templatetags/documents.py +++ b/src/documents/templatetags/documents.py @@ -3,7 +3,7 @@ # from django.urls import reverse from django import template -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ register = template.Library() diff --git a/src/documents/templatetags/wall.py b/src/documents/templatetags/wall.py index 4a6795be..486a2d6a 100644 --- a/src/documents/templatetags/wall.py +++ b/src/documents/templatetags/wall.py @@ -5,7 +5,7 @@ from datetime import timedelta from django.db.models import Q from django.urls import reverse from django import template -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from documents.models import Chunk, BookPublishRecord, Image, ImagePublishRecord diff --git a/src/documents/urls.py b/src/documents/urls.py index 602d4f22..1a1f1855 100644 --- a/src/documents/urls.py +++ b/src/documents/urls.py @@ -1,7 +1,7 @@ # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -from django.conf.urls import url +from django.urls import path, re_path from django.contrib.auth.decorators import permission_required from django.views.generic import RedirectView from .feeds import PublishTrackFeed @@ -9,58 +9,56 @@ from . import views urlpatterns = [ - url(r'^$', RedirectView.as_view(url='catalogue/', permanent=False)), + path('', RedirectView.as_view(url='catalogue/', permanent=False)), - url(r'^images/$', views.image_list, name='documents_image_list'), - url(r'^image/(?P[^/]+)/$', views.image, name="documents_image"), - url(r'^image/(?P[^/]+)/publish$', views.publish_image, + path('images/', views.image_list, name='documents_image_list'), + path('image//', views.image, name="documents_image"), + path('image//publish', views.publish_image, name="documents_publish_image"), - url(r'^catalogue/$', views.document_list, name='documents_document_list'), - url(r'^user/$', views.my, name='documents_user'), - url(r'^user/(?P[^/]+)/$', views.user, name='documents_user'), - url(r'^users/$', views.users, name='documents_users'), - url(r'^activity/$', views.activity, name='documents_activity'), - url(r'^activity/(?P\d{4}-\d{2}-\d{2})/$', + path('catalogue/', views.document_list, name='documents_document_list'), + path('user/', views.my, name='documents_user'), + path('user//', views.user, name='documents_user'), + path('users/', views.users, name='documents_users'), + path('activity/', views.activity, name='documents_activity'), + re_path(r'^activity/(?P\d{4}-\d{2}-\d{2})/$', views.activity, name='documents_activity'), - url(r'^upload/$', - views.upload, name='documents_upload'), + path('upload/', views.upload, name='documents_upload'), - url(r'^create/(?P[^/]*)/', - views.create_missing, name='documents_create_missing'), - url(r'^create/', + path('create//', views.create_missing, name='documents_create_missing'), + path('create/', views.create_missing, name='documents_create_missing'), - url(r'^book/(?P[^/]+)/publish$', views.publish, name="documents_publish"), + path('book//publish', views.publish, name="documents_publish"), - url(r'^book/(?P[^/]+)/$', views.book, name="documents_book"), - url(r'^book/(?P[^/]+)/gallery/$', + path('book//', views.book, name="documents_book"), + path('book//gallery/', permission_required('documents.change_book')(views.GalleryView.as_view()), name="documents_book_gallery"), - url(r'^book/(?P[^/]+)/xml$', views.book_xml, name="documents_book_xml"), - url(r'^book/dc/(?P[^/]+)/xml$', views.book_xml_dc, name="documents_book_xml_dc"), - url(r'^book/(?P[^/]+)/txt$', views.book_txt, name="documents_book_txt"), - url(r'^book/(?P[^/]+)/html$', views.book_html, name="documents_book_html"), - url(r'^book/(?P[^/]+)/epub$', views.book_epub, name="documents_book_epub"), - url(r'^book/(?P[^/]+)/mobi$', views.book_mobi, name="documents_book_mobi"), - url(r'^book/(?P[^/]+)/pdf$', views.book_pdf, name="documents_book_pdf"), - url(r'^book/(?P[^/]+)/pdf-mobile$', views.book_pdf, kwargs={'mobile': True}, name="documents_book_pdf_mobile"), + path('book//xml', views.book_xml, name="documents_book_xml"), + path('book/dc//xml', views.book_xml_dc, name="documents_book_xml_dc"), + path('book//txt', views.book_txt, name="documents_book_txt"), + path('book//html', views.book_html, name="documents_book_html"), + path('book//epub', views.book_epub, name="documents_book_epub"), + path('book//mobi', views.book_mobi, name="documents_book_mobi"), + path('book//pdf', views.book_pdf, name="documents_book_pdf"), + path('book//pdf-mobile', views.book_pdf, kwargs={'mobile': True}, name="documents_book_pdf_mobile"), - url(r'^chunk_add/(?P[^/]+)/(?P[^/]+)/$', + path('chunk_add///', views.chunk_add, name="documents_chunk_add"), - url(r'^chunk_edit/(?P[^/]+)/(?P[^/]+)/$', + path('chunk_edit///', views.chunk_edit, name="documents_chunk_edit"), - url(r'^book_append/(?P[^/]+)/$', + path('book_append//', views.book_append, name="documents_book_append"), - url(r'^chunk_mass_edit', + path('chunk_mass_edit', views.chunk_mass_edit, name='documents_chunk_mass_edit'), - url(r'^image_mass_edit', + path('image_mass_edit', views.image_mass_edit, name='documents_image_mass_edit'), - url(r'^track/(?P[^/]*)/$', PublishTrackFeed()), - url(r'^active/$', views.active_users_list, name='active_users_list'), + path('track//', PublishTrackFeed()), + path('active/', views.active_users_list, name='active_users_list'), - url(r'^mark-final/$', views.mark_final, name='mark_final'), - url(r'^mark-final-completed/$', views.mark_final_completed, name='mark_final_completed'), + path('mark-final/', views.mark_final, name='mark_final'), + path('mark-final-completed/', views.mark_final_completed, name='mark_final_completed'), ] diff --git a/src/documents/views.py b/src/documents/views.py index 38e69c1b..6c9f29e3 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -5,7 +5,7 @@ from collections import defaultdict from datetime import datetime, date, timedelta import logging import os -from urllib.parse import unquote, urlsplit, urlunsplit +from urllib.parse import quote_plus, unquote, urlsplit, urlunsplit from django.conf import settings from django.contrib import auth @@ -19,8 +19,7 @@ from django.http import Http404, HttpResponse, HttpResponseForbidden from django.http.response import HttpResponseRedirect from django.shortcuts import get_object_or_404, render from django.utils.encoding import iri_to_uri -from django.utils.http import urlquote_plus -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.decorators.http import require_POST from django_cas_ng.decorators import user_passes_test diff --git a/src/dvcs/models.py b/src/dvcs/models.py index 978f0720..5d465caf 100644 --- a/src/dvcs/models.py +++ b/src/dvcs/models.py @@ -11,7 +11,7 @@ from django.core.files.storage import FileSystemStorage from django.db import models, transaction from django.db.models.base import ModelBase from django.utils.text import format_lazy -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ import merge3 from django.conf import settings diff --git a/src/dvcs/signals.py b/src/dvcs/signals.py index 14f37f40..d129cf97 100644 --- a/src/dvcs/signals.py +++ b/src/dvcs/signals.py @@ -4,4 +4,4 @@ from django.dispatch import Signal post_commit = Signal() -post_publishable = Signal(providing_args=['publishable']) +post_publishable = Signal() diff --git a/src/email_mangler/templatetags/email.py b/src/email_mangler/templatetags/email.py index dbf29396..c0503ec5 100644 --- a/src/email_mangler/templatetags/email.py +++ b/src/email_mangler/templatetags/email.py @@ -4,7 +4,7 @@ import codecs from django.utils.html import escape from django.utils.safestring import mark_safe -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django import template register = template.Library() diff --git a/src/redakcja/urls.py b/src/redakcja/urls.py index 2f36af18..e4078851 100644 --- a/src/redakcja/urls.py +++ b/src/redakcja/urls.py @@ -1,7 +1,6 @@ # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -from django.conf.urls import url from django.urls import include, path from django.contrib import admin from django.conf import settings @@ -17,17 +16,17 @@ urlpatterns = [ #url(r'^admin/logout/$', django_cas_ng.views.logout, name='logout'), # Admin panel - url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - url(r'^admin/', admin.site.urls), + path('admin/doc/', include('django.contrib.admindocs.urls')), + path('admin/', admin.site.urls), path('catalogue/', include('catalogue.urls')), - url(r'^$', RedirectView.as_view(url='/documents/', permanent=False)), - url(r'^documents/', include('documents.urls')), - url(r'^apiclient/', include('apiclient.urls')), - url(r'^editor/', include('wiki.urls')), - url(r'^images/', include('wiki_img.urls')), - url(r'^cover/', include('cover.urls')), - url(r'^depot/', include('depot.urls')), - url(r'^wlxml/', include('wlxml.urls')), + path('', RedirectView.as_view(url='/documents/', permanent=False)), + path('documents/', include('documents.urls')), + path('apiclient/', include('apiclient.urls')), + path('editor/', include('wiki.urls')), + path('images/', include('wiki_img.urls')), + path('cover/', include('cover.urls')), + path('depot/', include('depot.urls')), + path('wlxml/', include('wlxml.urls')), path('api/', include('redakcja.api.urls')), ] @@ -35,14 +34,14 @@ urlpatterns = [ if settings.CAS_SERVER_URL: urlpatterns += [ - url(r'^accounts/login/$', django_cas_ng.views.LoginView.as_view(), name='cas_ng_login'), - url(r'^accounts/logout/$', django_cas_ng.views.LogoutView.as_view(), name='logout'), + path('accounts/login/', django_cas_ng.views.LoginView.as_view(), name='cas_ng_login'), + path('accounts/logout/', django_cas_ng.views.LogoutView.as_view(), name='logout'), ] else: import django.contrib.auth.views urlpatterns += [ - url(r'^accounts/login/$', django.contrib.auth.views.LoginView.as_view(), name='cas_ng_login'), - url(r'^accounts/', include('django.contrib.auth.urls')), + path('accounts/login/', django.contrib.auth.views.LoginView.as_view(), name='cas_ng_login'), + path('accounts/', include('django.contrib.auth.urls')), ] @@ -51,4 +50,4 @@ if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) import debug_toolbar - urlpatterns += [url(r'^__debug__/', include(debug_toolbar.urls))] + urlpatterns += [path('__debug__/', include(debug_toolbar.urls))] diff --git a/src/toolbar/admin.py b/src/toolbar/admin.py index 1fa695b2..cb6de45c 100644 --- a/src/toolbar/admin.py +++ b/src/toolbar/admin.py @@ -2,7 +2,7 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django.contrib import admin -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django import forms import json diff --git a/src/toolbar/models.py b/src/toolbar/models.py index 02567fab..a221e04b 100644 --- a/src/toolbar/models.py +++ b/src/toolbar/models.py @@ -2,7 +2,7 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class ButtonGroup(models.Model): diff --git a/src/wiki/forms.py b/src/wiki/forms.py index 084ae46d..46194677 100644 --- a/src/wiki/forms.py +++ b/src/wiki/forms.py @@ -2,7 +2,7 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django import forms -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from documents.models import Chunk diff --git a/src/wiki/models.py b/src/wiki/models.py index 456e2195..b3cb9d8e 100644 --- a/src/wiki/models.py +++ b/src/wiki/models.py @@ -2,7 +2,7 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ import logging logger = logging.getLogger("fnp.wiki") diff --git a/src/wiki/urls.py b/src/wiki/urls.py index f1a45087..f2fa3f5d 100644 --- a/src/wiki/urls.py +++ b/src/wiki/urls.py @@ -1,37 +1,27 @@ # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -from django.conf.urls import url +from django.urls import path from . import views urlpatterns = [ - url(r'^edit/(?P[^/]+)/(?:(?P[^/]+)/)?$', - views.editor, name="wiki_editor"), - - url(r'^readonly/(?P[^/]+)/(?:(?P[^/]+)/)?$', - views.editor_readonly, name="wiki_editor_readonly"), - - url(r'^gallery/(?P[^/]+)/$', - views.gallery, name="wiki_gallery"), - - url(r'^history/(?P\d+)/$', - views.history, name="wiki_history"), - - url(r'^rev/(?P\d+)/$', - views.revision, name="wiki_revision"), - - url(r'^text/(?P\d+)/$', - views.text, name="wiki_text"), - - url(r'^revert/(?P\d+)/$', - views.revert, name='wiki_revert'), - - url(r'^diff/(?P\d+)/$', views.diff, name="wiki_diff"), - url(r'^pubmark/(?P\d+)/$', views.pubmark, name="wiki_pubmark"), - - url(r'^themes$', views.themes, name="themes"), - - url(r'^back/$', views.back), - url(r'^editor-user-area/$', views.editor_user_area), + path('edit///', views.editor, name="wiki_editor"), + path('edit//', views.editor, name="wiki_editor"), + + path('readonly///', + views.editor_readonly, name="wiki_editor_readonly"), + path('readonly//', + views.editor_readonly, name="wiki_editor_readonly"), + + path('gallery//', views.gallery, name="wiki_gallery"), + path('history//', views.history, name="wiki_history"), + path('rev//', views.revision, name="wiki_revision"), + path('text//', views.text, name="wiki_text"), + path('revert//', views.revert, name='wiki_revert'), + path('diff//', views.diff, name="wiki_diff"), + path('pubmark//', views.pubmark, name="wiki_pubmark"), + path('themes', views.themes, name="themes"), + path('back/', views.back), + path('editor-user-area/', views.editor_user_area), ] diff --git a/src/wiki/views.py b/src/wiki/views.py index 7bcea51f..cf67abbd 100644 --- a/src/wiki/views.py +++ b/src/wiki/views.py @@ -14,7 +14,7 @@ from django.http import Http404, HttpResponseForbidden from django.middleware.gzip import GZipMiddleware from django.utils.decorators import decorator_from_middleware from django.utils.formats import localize -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators.http import require_POST, require_GET from django.shortcuts import get_object_or_404, render diff --git a/src/wiki_img/forms.py b/src/wiki_img/forms.py index 43b1a253..49d7845d 100644 --- a/src/wiki_img/forms.py +++ b/src/wiki_img/forms.py @@ -2,7 +2,7 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django import forms -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from wiki.forms import DocumentTextSaveForm from documents.models import Image diff --git a/src/wiki_img/urls.py b/src/wiki_img/urls.py index 82244841..0c9e8482 100644 --- a/src/wiki_img/urls.py +++ b/src/wiki_img/urls.py @@ -1,26 +1,26 @@ # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -from django.conf.urls import url +from django.urls import path from . import views urlpatterns = [ - url(r'^edit/(?P[^/]+)/$', + path('edit//', views.editor, name="wiki_img_editor"), - url(r'^readonly/(?P[^/]+)/$', + path('readonly//', views.editor_readonly, name="wiki_img_editor_readonly"), - url(r'^text/(?P\d+)/$', + path('text//', views.text, name="wiki_img_text"), - url(r'^history/(?P\d+)/$', + path('history//', views.history, name="wiki_img_history"), - url(r'^revert/(?P\d+)/$', + path('revert//', views.revert, name='wiki_img_revert'), - url(r'^diff/(?P\d+)/$', views.diff, name="wiki_img_diff"), - url(r'^pubmark/(?P\d+)/$', views.pubmark, name="wiki_img_pubmark"), + path('diff//', views.diff, name="wiki_img_diff"), + path('pubmark//', views.pubmark, name="wiki_img_pubmark"), ] diff --git a/src/wiki_img/views.py b/src/wiki_img/views.py index 7fc5c700..a3135286 100644 --- a/src/wiki_img/views.py +++ b/src/wiki_img/views.py @@ -15,7 +15,7 @@ from django.shortcuts import get_object_or_404, render from django.views.decorators.http import require_GET, require_POST from django.conf import settings from django.utils.formats import localize -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from documents.models import Image from wiki import forms -- 2.20.1