Skip to content

Commit

Permalink
fix: [AXM-1302] redirect to accredible group when save penalty (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrylo-kh authored Jan 10, 2025
1 parent 51a03a7 commit 6ee05ba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions credentials/apps/badges/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<a href="{}">{}</a>', url, instance.template)

template_link.short_description = _("badge template")
Expand All @@ -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)


Expand Down

0 comments on commit 6ee05ba

Please sign in to comment.