From 6ee05bad2e5850b5ddc41b43688b502755d28389 Mon Sep 17 00:00:00 2001 From: Kyrylo Kholodenko Date: Fri, 10 Jan 2025 10:14:56 +0200 Subject: [PATCH] fix: [AXM-1302] redirect to accredible group when save penalty (#195) --- credentials/apps/badges/admin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/credentials/apps/badges/admin.py b/credentials/apps/badges/admin.py index 516831e2d..64b236327 100644 --- a/credentials/apps/badges/admin.py +++ b/credentials/apps/badges/admin.py @@ -455,7 +455,9 @@ def template_link(self, instance): """ Interactive link to parent (badge template). """ - url = reverse("admin:badges_credlybadgetemplate_change", args=[instance.template.pk]) + reverse_name = ADMIN_CHANGE_VIEW_REVERSE_NAMES.get(instance.template.origin, "admin:index") + reverse_args = [] if reverse_name == "admin:index" else [instance.template.pk] + url = reverse(reverse_name, args=reverse_args) return format_html('{}', url, instance.template) template_link.short_description = _("badge template") @@ -470,7 +472,9 @@ def formfield_for_manytomany(self, db_field, request, **kwargs): def response_change(self, request, obj): if "_save" in request.POST: - return HttpResponseRedirect(reverse("admin:badges_credlybadgetemplate_change", args=[obj.template.pk])) + reverse_name = ADMIN_CHANGE_VIEW_REVERSE_NAMES.get(obj.template.origin, "admin:index") + reverse_args = [] if reverse_name == "admin:index" else [obj.template.pk] + return HttpResponseRedirect(reverse(reverse_name, args=reverse_args)) return super().response_change(request, obj)