diff --git a/autocomplete/widgets.py b/autocomplete/widgets.py index e144516..ac01ec5 100644 --- a/autocomplete/widgets.py +++ b/autocomplete/widgets.py @@ -9,8 +9,8 @@ from django.http import HttpResponse, HttpResponseRedirect from django.contrib.admin.widgets import RelatedFieldWidgetWrapper -from django.utils.translation import ugettext as _ -from django.utils.encoding import force_text +from django.utils.translation import gettext as _ +from django.utils.encoding import force_str from django.utils.html import escape from django.utils.datastructures import MultiValueDict @@ -259,7 +259,7 @@ def response_add(self, request, obj, post_url_continue='../%s/'): opts = obj._meta pk_value = obj._get_pk_val() - msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': force_text(opts.verbose_name), 'obj': force_text(obj)} + msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': force_str(opts.verbose_name), 'obj': force_str(obj)} # Here, we distinguish between different save types by checking for # the presence of keys in request.POST. if '_continue' in request.POST: @@ -274,7 +274,7 @@ def response_add(self, request, obj, post_url_continue='../%s/'): return HttpResponse('' % (escape(pk_value), escape(obj))) elif '_addanother' in request.POST: - self.message_user(request, msg + ' ' + (_("You may add another %s below.") % force_text(opts.verbose_name))) + self.message_user(request, msg + ' ' + (_("You may add another %s below.") % force_str(opts.verbose_name))) return HttpResponseRedirect(request.path) else: self.message_user(request, msg) diff --git a/countries/models.py b/countries/models.py index ce4849c..6099ea8 100644 --- a/countries/models.py +++ b/countries/models.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class Country(models.Model): diff --git a/lp/urls.py b/lp/urls.py index 9316380..bf10448 100644 --- a/lp/urls.py +++ b/lp/urls.py @@ -1,10 +1,10 @@ -from django.conf.urls import url +from django.urls import path from lp import views urlpatterns = [ - url(r'^edition/$', views.edition), - url(r'^sample/$', views.sample), - url(r'^meta.json$', views.meta_json), - url(r'^icon.png$', views.icon), + path('edition/', views.edition), + path('sample/', views.sample), + path('meta.json', views.meta_json), + path('icon.png', views.icon), ] diff --git a/merged/tests.py b/merged/tests.py index d19b884..45c29f4 100644 --- a/merged/tests.py +++ b/merged/tests.py @@ -6,31 +6,31 @@ class MergeTest(TestCase): def test_doing_a_merge(self): - make_production( + hamlet1 = make_production( 'Hamlet', 'A tragedy', ['Shakespeare Productions'], [{'name': 'Theatre', 'start': '2013-01-01', 'end': '2013-01-14'}] ) - make_production( + hamlet2 = make_production( 'Hamlet', 'A tragedy', ['Shakespeare Productions'], [{'name': 'Stirchley Theatre', 'start': '2013-01-01', 'end': '2013-01-14'}] ) - resp = self.client.get('/play/1/hamlet/production/1') + resp = self.client.get(hamlet1.get_absolute_url()) self.assertContains(resp, 'Hamlet') - resp = self.client.get('/play/1/hamlet/production/2') + resp = self.client.get(hamlet2.get_absolute_url()) self.assertContains(resp, 'Hamlet') - resp = self.client.get('/play/1/hamlet/production/2/merge') + resp = self.client.get(hamlet2.get_absolute_url() + '/merge') self.assertContains(resp, 'Thanks for helping improve the accuracy of the site.') - resp = self.client.get('/play/1/hamlet/production/2') + resp = self.client.get(hamlet2.get_absolute_url()) self.assertNotContains(resp, 'This is a duplicate') - resp = self.client.get('/play/1/hamlet/production/1') + resp = self.client.get(hamlet1.get_absolute_url()) self.assertContains(resp, 'This is a duplicate of Shakespeare Productions production of Hamlet') - resp = self.client.post('/play/1/hamlet/production/1/merge', {'dupe': True}) + resp = self.client.post(hamlet1.get_absolute_url() + '/merge', {'dupe': True}) self.assertContains(resp, 'Thanks again for helping') self.assertEqual(len(mail.outbox), 1) - resp = self.client.post('/play/1/hamlet/production/1/merge', {'stop': True}, follow=True) - self.assertRedirects(resp, '/play/1/hamlet/production/1') + resp = self.client.post(hamlet1.get_absolute_url() + '/merge', {'stop': True}, follow=True) + self.assertRedirects(resp, hamlet1.get_absolute_url()) diff --git a/productions/models.py b/productions/models.py index 8febf82..9754efa 100644 --- a/productions/models.py +++ b/productions/models.py @@ -314,7 +314,7 @@ class Part(models.Model): person = models.ForeignKey(Person, on_delete=models.CASCADE) role = models.CharField( u'R\u00f4le', max_length=200, blank=True, help_text=u'e.g. \u201cRomeo\u201d or \u201cDirector\u201d') - cast = models.NullBooleanField( + cast = models.BooleanField( null=True, blank=True, verbose_name='Cast/Crew', help_text=u'Crew includes all non-cast, from director to musicians to producers') credited_as = models.CharField( diff --git a/profiles/models.py b/profiles/models.py index 7a69c2c..b8ae4e2 100644 --- a/profiles/models.py +++ b/profiles/models.py @@ -2,7 +2,7 @@ from django.conf import settings from django.contrib.auth.models import AbstractUser from django.urls import reverse -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class User(AbstractUser): diff --git a/profiles/views.py b/profiles/views.py index 5fd93a9..770d05c 100644 --- a/profiles/views.py +++ b/profiles/views.py @@ -1,16 +1,10 @@ from django.http import HttpResponseRedirect, Http404 from django.contrib.auth.tokens import PasswordResetTokenGenerator -from django.contrib.sites.shortcuts import get_current_site from django.contrib.auth.decorators import login_required from django.shortcuts import get_object_or_404 -from django.contrib.auth import REDIRECT_FIELD_NAME, login as auth_login -from django.conf import settings -from django.shortcuts import render, resolve_url -from django.template.response import TemplateResponse -from django.utils.http import is_safe_url -from django.views.decorators.cache import never_cache -from django.views.decorators.csrf import csrf_protect -from django.views.decorators.debug import sensitive_post_parameters +from django.contrib.auth import login as auth_login +from django.contrib.auth.views import LoginView as DjangoLoginView +from django.shortcuts import render from django.db.models import Q, Min from django.db.models.expressions import RawSQL @@ -79,46 +73,8 @@ def register(request): return render(request, 'registration/register.html', {'form': form}) -@sensitive_post_parameters() -@csrf_protect -@never_cache -def login(request, template_name='registration/login.html', - redirect_field_name=REDIRECT_FIELD_NAME, - authentication_form=AuthenticationForm, - extra_context=None): - """ - Displays the login form and handles the login action. - """ - redirect_to = request.POST.get(redirect_field_name, - request.GET.get(redirect_field_name, '')) - - if request.method == "POST": - form = authentication_form(request, data=request.POST) - if form.is_valid(): - - # Ensure the user-originating redirection url is safe. - if not is_safe_url(url=redirect_to, allowed_hosts=request.get_host()): - redirect_to = resolve_url(settings.LOGIN_REDIRECT_URL) - - # Okay, security check complete. Log the user in. - auth_login(request, form.get_user()) - - return HttpResponseRedirect(redirect_to) - else: - form = authentication_form(request) - - current_site = get_current_site(request) - - context = { - 'form': form, - redirect_field_name: redirect_to, - 'site': current_site, - 'site_name': current_site.name, - } - if extra_context is not None: - context.update(extra_context) - - return TemplateResponse(request, template_name, context) +class LoginView(DjangoLoginView): + form_class = AuthenticationForm # def registration_complete(request): diff --git a/requirements-base.txt b/requirements-base.txt index 2720940..ed2af8a 100644 --- a/requirements-base.txt +++ b/requirements-base.txt @@ -1,8 +1,10 @@ mysqlclient==2.0.2 Pillow==10.1.0 +# Upgrade to 8.0.0 when DJ3 django-cleanup==6.0.0 django-contrib-comments==2.2.0 -django-nose==1.4.7 -django-reversion==3.0.7 +# Upgrade to 5.0.8 when DJ3 +django-reversion==4.0.2 +# Upgrade to 12.10.0 when running on DJ3 sorl-thumbnail==12.8.0 python-dateutil==2.8.2 diff --git a/templates/admin/edit_part_inline.html b/templates/admin/edit_part_inline.html index 8b88bf4..ff60ee3 100644 --- a/templates/admin/edit_part_inline.html +++ b/templates/admin/edit_part_inline.html @@ -29,9 +29,9 @@