Add next URL support to generic DeleteView

pull/10072/head
Sage Abdullah 2023-02-16 17:11:49 +00:00
rodzic daf265873e
commit ccf53cee83
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
1 zmienionych plików z 4 dodań i 0 usunięć

Wyświetl plik

@ -649,6 +649,9 @@ class DeleteView(
return ReferenceIndex.get_references_to(self.object).group_by_source_object()
def get_success_url(self):
next_url = get_valid_next_url_from_request(self.request)
if next_url:
return next_url
if not self.index_url_name:
raise ImproperlyConfigured(
"Subclasses of wagtail.admin.views.generic.models.DeleteView must provide an "
@ -704,6 +707,7 @@ class DeleteView(
context = super().get_context_data(**kwargs)
context["model_opts"] = self.object._meta
context["usage_url"] = self.get_usage_url()
context["next"] = self.get_success_url()
if context["usage_url"]:
# Get this here instead of the template so that we do not iterate through
# the usage and potentially trigger a database query for each item