Skip to content

Commit

Permalink
Merge pull request #636 from drnlm/feature/fix_django4_warnings
Browse files Browse the repository at this point in the history
Feature/fix django4 warnings
  • Loading branch information
drnlm committed Jun 16, 2022
2 parents a64761d + d926ecc commit 06de5da
Show file tree
Hide file tree
Showing 26 changed files with 90 additions and 91 deletions.
2 changes: 1 addition & 1 deletion docs/menus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Sub-menu have the keys:

Example snippet from ``settings.py``::

from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.core.urlresolvers import reverse_lazy

WAFER_MENUS += (
Expand Down
12 changes: 6 additions & 6 deletions wafer/compare/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from diff_match_patch import diff_match_patch
import datetime

from django.conf.urls import url
from django.urls import re_path
from django.contrib.admin import SimpleListFilter
from django.contrib.admin.utils import unquote, quote
from django.contrib.contenttypes.models import ContentType
from django.shortcuts import get_object_or_404, render
from django.utils.encoding import force_text
from django.utils.translation import ugettext as _
from django.utils.encoding import force_str
from django.utils.translation import gettext as _
from django.urls import reverse

from markitup.fields import Markup
Expand Down Expand Up @@ -98,7 +98,7 @@ def make_diff(current, revision):
continue
else:
# Compare the actual field values
diffs = dmp.diff_main(force_text(old_val), force_text(cur_val))
diffs = dmp.diff_main(force_str(old_val), force_str(cur_val))
patch = dmp.diff_prettyHtml(diffs)
the_diff.append((field, patch))

Expand All @@ -118,9 +118,9 @@ def get_urls(self):
urls = super().get_urls()
opts = self.model._meta
compare_urls = [
url("^([^/]+)/([^/]+)/compare/$", self.admin_site.admin_view(self.compare_view),
re_path("^([^/]+)/([^/]+)/compare/$", self.admin_site.admin_view(self.compare_view),
name='%s_%s_compare' % (opts.app_label, opts.model_name)),
url("^([^/]+)/comparelist/$", self.admin_site.admin_view(self.comparelist_view),
re_path("^([^/]+)/comparelist/$", self.admin_site.admin_view(self.comparelist_view),
name='%s_%s_comparelist' % (opts.app_label, opts.model_name)),
]
return compare_urls + urls
Expand Down
4 changes: 2 additions & 2 deletions wafer/kv/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import include, url
from django.urls import include, re_path

from rest_framework import routers

Expand All @@ -8,5 +8,5 @@
router.register(r'kv', KeyValueViewSet)

urlpatterns = [
url(r'^api/', include(router.urls)),
re_path(r'^api/', include(router.urls)),
]
2 changes: 1 addition & 1 deletion wafer/pages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.db import models
from django.db.models.signals import post_save
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from markitup.fields import MarkupField

Expand Down
9 changes: 4 additions & 5 deletions wafer/pages/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.conf.urls import include, url
from django.urls import get_script_prefix
from django.urls import include, re_path, get_script_prefix
from django.views.generic import RedirectView

from rest_framework import routers
Expand All @@ -10,8 +9,8 @@
router.register(r'pages', PageViewSet)

urlpatterns = [
url(r'^api/', include(router.urls)),
url(r'^index(?:\.html)?/?$', RedirectView.as_view(
re_path(r'^api/', include(router.urls)),
re_path(r'^index(?:\.html)?/?$', RedirectView.as_view(
url=get_script_prefix(), permanent=True, query_string=True)),
url(r'^(?:(.+)/)?$', slug, name='wafer_page'),
re_path(r'^(?:(.+)/)?$', slug, name='wafer_page'),
]
2 changes: 1 addition & 1 deletion wafer/registration/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.conf import settings
from django.urls import reverse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Hidden, Submit
Expand Down
12 changes: 6 additions & 6 deletions wafer/registration/urls.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from django.conf.urls import include, url
from django.urls import include, re_path

from wafer.registration.views import (
github_login, gitlab_login, redirect_profile)


urlpatterns = [
url(r'^profile/$', redirect_profile),
re_path(r'^profile/$', redirect_profile),

url(r'^github-login/$', github_login),
url(r'^gitlab-login/$', gitlab_login),
re_path(r'^github-login/$', github_login),
re_path(r'^gitlab-login/$', gitlab_login),

url(r'', include('registration.backends.default.urls')),
url(r'', include('registration.auth_urls')),
re_path(r'', include('registration.backends.default.urls')),
re_path(r'', include('registration.auth_urls')),
]
12 changes: 6 additions & 6 deletions wafer/schedule/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from collections import defaultdict

from django.db.models import Q
from django.conf.urls import url
from django.urls import re_path
from django.core.exceptions import ValidationError

from django.contrib import admin
from django.contrib import messages
from django.utils.encoding import force_text
from django.utils.translation import ugettext as _
from django.utils.encoding import force_str
from django.utils.translation import gettext as _
from django import forms
from reversion.admin import VersionAdmin

Expand Down Expand Up @@ -366,8 +366,8 @@ def get_urls(self):
admin_schedule_edit_view = self.admin_site.admin_view(
ScheduleEditView.as_view())
my_urls = [
url(r'^edit/$', admin_schedule_edit_view, name='schedule_editor'),
url(r'^edit/(?P<block_id>[0-9]+)$', admin_schedule_edit_view,
re_path(r'^edit/$', admin_schedule_edit_view, name='schedule_editor'),
re_path(r'^edit/(?P<block_id>[0-9]+)$', admin_schedule_edit_view,
name='schedule_editor'),
]
return my_urls + urls
Expand Down Expand Up @@ -448,7 +448,7 @@ def save_model(self, request, obj, form, change):
try:
new_slot.full_clean()
new_slot.save()
msgdict = {'obj': force_text(new_slot)}
msgdict = {'obj': force_str(new_slot)}
msg = _("Additional slot %(obj)s added sucessfully") % msgdict
if hasattr(request, '_messages'):
# Don't add messages unless we have a suitable request
Expand Down
2 changes: 1 addition & 1 deletion wafer/schedule/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.db.models.signals import post_save, post_delete
from django.urls import reverse
from django.utils.crypto import salted_hmac
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.timezone import localtime

from wafer.pages.models import Page
Expand Down
1 change: 0 additions & 1 deletion wafer/schedule/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ def test_time_filter_lookups(self):
TestFilter = self._make_time_filter('11:00')
# Check lookup details
lookups = list(TestFilter.lookups(None, self.admin))
print(lookups)
self.assertEqual(len(lookups), 3)
self.assertEqual(lookups[0], ('11:00', '11:00'))
TestFilter = self._make_time_filter('12:00')
Expand Down
16 changes: 8 additions & 8 deletions wafer/schedule/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import include, url
from django.urls import include, re_path
from rest_framework import routers


Expand All @@ -10,12 +10,12 @@
router.register(r'scheduleitems', ScheduleItemViewSet)

urlpatterns = [
url(r'^$', ScheduleView.as_view(), name='wafer_full_schedule'),
url(r'^venue/(?P<pk>\d+)/$', VenueView.as_view(), name='wafer_venue'),
url(r'^current/$', CurrentView.as_view(), name='wafer_current'),
url(r'^pentabarf\.xml$', ScheduleXmlView.as_view(),
re_path(r'^$', ScheduleView.as_view(), name='wafer_full_schedule'),
re_path(r'^venue/(?P<pk>\d+)/$', VenueView.as_view(), name='wafer_venue'),
re_path(r'^current/$', CurrentView.as_view(), name='wafer_current'),
re_path(r'^pentabarf\.xml$', ScheduleXmlView.as_view(),
name='wafer_pentabarf_xml'),
url(r'^schedule\.ics$', ICalView.as_view(), name="schedule.ics"),
url(r'^schedule\.json$', JsonDataView.as_view(), name="schedule.json"),
url(r'^api/', include(router.urls)),
re_path(r'^schedule\.ics$', ICalView.as_view(), name="schedule.ics"),
re_path(r'^schedule\.json$', JsonDataView.as_view(), name="schedule.json"),
re_path(r'^api/', include(router.urls)),
]
2 changes: 1 addition & 1 deletion wafer/schedule/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def lookup_highlighted_venue(request):
if Venue.objects.get(pk=int(venue_id)):
return int(venue_id)
except (ValueError, Venue.DoesNotExist):
logger.warn('Invalid venue id passed to schedule: %s' % venue_id)
logger.warning('Invalid venue id passed to schedule: %s' % venue_id)
return None


Expand Down
3 changes: 2 additions & 1 deletion wafer/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

# Django settings for wafer project.

Expand Down Expand Up @@ -106,6 +106,7 @@
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.request',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
Expand Down
2 changes: 1 addition & 1 deletion wafer/sponsors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.db import models
from django.db.models.signals import post_save
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from markitup.fields import MarkupField

Expand Down
10 changes: 5 additions & 5 deletions wafer/sponsors/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import url, include
from django.urls import re_path, include
from rest_framework import routers

from wafer.sponsors.views import (
Expand All @@ -10,10 +10,10 @@
router.register(r'packages', PackageViewSet)

urlpatterns = [
url(r'^$', ShowSponsors.as_view(),
re_path(r'^$', ShowSponsors.as_view(),
name='wafer_sponsors'),
url(r'^(?P<pk>\d+)/$', SponsorView.as_view(), name='wafer_sponsor'),
url(r'^packages/$', ShowPackages.as_view(),
re_path(r'^(?P<pk>\d+)/$', SponsorView.as_view(), name='wafer_sponsor'),
re_path(r'^packages/$', ShowPackages.as_view(),
name='wafer_sponsorship_packages'),
url(r'^api/', include(router.urls)),
re_path(r'^api/', include(router.urls)),
]
2 changes: 1 addition & 1 deletion wafer/talks/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib import admin
from django.db import models
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from reversion.admin import VersionAdmin

Expand Down
2 changes: 1 addition & 1 deletion wafer/talks/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.core.exceptions import FieldDoesNotExist
from django.urls import reverse
from django.utils.module_loading import import_string
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from crispy_forms.bootstrap import FormActions
from crispy_forms.helper import FormHelper
Expand Down
4 changes: 2 additions & 2 deletions wafer/talks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.urls import reverse
from django.utils.functional import lazy
from django.utils.text import format_lazy
from django.utils.translation import ugettext, ugettext_lazy as _
from django.utils.translation import gettext, gettext_lazy as _
from django.utils.timezone import now

import reversion
Expand Down Expand Up @@ -33,7 +33,7 @@ def render_author(author):


def authors_help():
_ = ugettext # This function will be wrapped for lazy evaluation
_ = gettext # This function will be wrapped for lazy evaluation
text = []
text.append(_("The speakers presenting the talk."))
if not settings.WAFER_PUBLIC_ATTENDEE_LIST:
Expand Down
24 changes: 12 additions & 12 deletions wafer/talks/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import url, include
from django.urls import re_path, include
from rest_framework_extensions import routers

from wafer.talks.views import (
Expand All @@ -14,20 +14,20 @@
parents_query_lookups=['talk'])

urlpatterns = [
url(r'^$', UsersTalks.as_view(), name='wafer_users_talks'),
url(r'^page/(?P<page>\d+)/$', UsersTalks.as_view(),
re_path(r'^$', UsersTalks.as_view(), name='wafer_users_talks'),
re_path(r'^page/(?P<page>\d+)/$', UsersTalks.as_view(),
name='wafer_users_talks_page'),
url(r'^new/$', TalkCreate.as_view(), name='wafer_talk_submit'),
url(r'^(?P<pk>\d+)(?:-(?P<slug>[\w-]*))?/$', TalkView.as_view(),
re_path(r'^new/$', TalkCreate.as_view(), name='wafer_talk_submit'),
re_path(r'^(?P<pk>\d+)(?:-(?P<slug>[\w-]*))?/$', TalkView.as_view(),
name='wafer_talk'),
url(r'^(?P<pk>\d+)/edit/$', TalkUpdate.as_view(),
re_path(r'^(?P<pk>\d+)/edit/$', TalkUpdate.as_view(),
name='wafer_talk_edit'),
url(r'^(?P<pk>\d+)/review/$', TalkReview.as_view(),
re_path(r'^(?P<pk>\d+)/review/$', TalkReview.as_view(),
name='wafer_talk_review'),
url(r'^(?P<pk>\d+)/withdraw/$', TalkWithdraw.as_view(),
re_path(r'^(?P<pk>\d+)/withdraw/$', TalkWithdraw.as_view(),
name='wafer_talk_withdraw'),
url(r'^speakers/$', Speakers.as_view(), name='wafer_talks_speakers'),
url(r'^tracks/', TracksView.as_view(), name='wafer_talk_tracks'),
url(r'^types/', TalkTypesView.as_view(), name='wafer_talk_types'),
url(r'^api/', include(router.urls)),
re_path(r'^speakers/$', Speakers.as_view(), name='wafer_talks_speakers'),
re_path(r'^tracks/', TracksView.as_view(), name='wafer_talk_tracks'),
re_path(r'^types/', TalkTypesView.as_view(), name='wafer_talk_types'),
re_path(r'^api/', include(router.urls)),
]
2 changes: 1 addition & 1 deletion wafer/tickets/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from django import forms
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.core.exceptions import ValidationError

from wafer.tickets.models import Ticket
Expand Down
10 changes: 5 additions & 5 deletions wafer/tickets/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import include, url
from django.urls import include, re_path

from rest_framework import routers

Expand All @@ -15,8 +15,8 @@
router.register(r'tickettypes', TicketTypesViewSet)

urlpatterns = [
url(r'^claim/$', ClaimView.as_view(), name='wafer_ticket_claim'),
url(r'^zapier_guest_hook/$', zapier_guest_hook),
url(r'^zapier_cancel_hook/$', zapier_cancel_hook),
url(r'^api/', include(router.urls)),
re_path(r'^claim/$', ClaimView.as_view(), name='wafer_ticket_claim'),
re_path(r'^zapier_guest_hook/$', zapier_guest_hook),
re_path(r'^zapier_cancel_hook/$', zapier_cancel_hook),
re_path(r'^api/', include(router.urls)),
]
24 changes: 12 additions & 12 deletions wafer/urls.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from django.conf.urls import include, url
from django.urls import include, re_path
from django.conf.urls.static import static
from django.conf import settings
from django.contrib import admin

admin.autodiscover()

urlpatterns = [
url(r'^accounts/', include('wafer.registration.urls')),
url(r'^users/', include('wafer.users.urls')),
url(r'^talks/', include('wafer.talks.urls')),
url(r'^sponsors/', include('wafer.sponsors.urls')),
url(r'^pages/', include('wafer.pages.urls')),
url(r'^admin/', admin.site.urls),
url(r'^markitup/', include('markitup.urls')),
url(r'^schedule/', include('wafer.schedule.urls')),
url(r'^tickets/', include('wafer.tickets.urls')),
url(r'^kv/', include('wafer.kv.urls')),
re_path(r'^accounts/', include('wafer.registration.urls')),
re_path(r'^users/', include('wafer.users.urls')),
re_path(r'^talks/', include('wafer.talks.urls')),
re_path(r'^sponsors/', include('wafer.sponsors.urls')),
re_path(r'^pages/', include('wafer.pages.urls')),
re_path(r'^admin/', admin.site.urls),
re_path(r'^markitup/', include('markitup.urls')),
re_path(r'^schedule/', include('wafer.schedule.urls')),
re_path(r'^tickets/', include('wafer.tickets.urls')),
re_path(r'^kv/', include('wafer.kv.urls')),
]

# Serve media
Expand All @@ -24,4 +24,4 @@
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

# Pages occupy the entire URL space, and must come last
urlpatterns.append(url(r'', include('wafer.pages.urls')))
urlpatterns.append(re_path(r'', include('wafer.pages.urls')))

0 comments on commit 06de5da

Please sign in to comment.