mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-31 06:56:33 +02:00
Fix logic and additional unit tests
This commit is contained in:
parent
95d912ecbc
commit
16e251c4fc
3 changed files with 82 additions and 26 deletions
|
@ -1519,8 +1519,7 @@ class DomainInvitationAdmin(BaseInvitationAdmin):
|
|||
change_form_template = "django/admin/domain_invitation_change_form.html"
|
||||
|
||||
def change_view(self, request, object_id, form_url="", extra_context=None):
|
||||
"""Override the change_view to add the invitation obj for the
|
||||
change_form_object_tools template"""
|
||||
"""Override the change_view to add the invitation obj for the change_form_object_tools template"""
|
||||
|
||||
if extra_context is None:
|
||||
extra_context = {}
|
||||
|
@ -1529,6 +1528,15 @@ class DomainInvitationAdmin(BaseInvitationAdmin):
|
|||
invitation = get_object_or_404(DomainInvitation, id=object_id)
|
||||
extra_context["invitation"] = invitation
|
||||
|
||||
if request.method == "POST" and "cancel_invitation" in request.POST:
|
||||
if invitation.status == DomainInvitation.DomainInvitationStatus.INVITED:
|
||||
invitation.cancel_invitation()
|
||||
invitation.save(update_fields=["status"])
|
||||
messages.success(request, _("Invitation canceled successfully."))
|
||||
|
||||
# Redirect back to the change view
|
||||
return redirect(reverse("admin:registrar_domaininvitation_change", args=[object_id]))
|
||||
|
||||
return super().change_view(request, object_id, form_url, extra_context)
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue