dnscms: improve associations app

This commit is contained in:
2026-05-19 21:49:38 +02:00
parent 4a264c589d
commit 29c61ffc76
11 changed files with 295 additions and 95 deletions
+3 -20
View File
@@ -1,15 +1,12 @@
from urllib.parse import urlencode
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import gettext, gettext_lazy as _
from django.utils.translation import ngettext
from wagtail.admin.ui.tables import Column, DateColumn
from wagtail.admin.ui.tables.pages import PageStatusColumn, PageTitleColumn
from wagtail.admin.views.pages.choose_parent import ChooseParentView
from wagtail.admin.views.pages.listing import IndexView
from wagtail.admin.viewsets.pages import PageListingViewSet
from dnscms.admin import ListingRedirectChooseParentView
from events.models import EventPage
@@ -44,22 +41,8 @@ class EventPageIndexView(IndexView):
)
class EventChooseParentView(ChooseParentView):
"""Redirect newly-created EventPages back to the events listing."""
def _with_next(self, response):
if response.status_code != 302:
return response
url = response["Location"]
sep = "&" if "?" in url else "?"
response["Location"] = f"{url}{sep}{urlencode({'next': reverse('events:index')})}"
return response
def get(self, request, *args, **kwargs):
return self._with_next(super().get(request, *args, **kwargs))
def form_valid(self, form):
return self._with_next(super().form_valid(form))
class EventChooseParentView(ListingRedirectChooseParentView):
listing_url_name = "events:index"
class EventPageListingViewSet(PageListingViewSet):