mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-20 01:36:00 +02:00
Cancel removed from retrieved invitations, cancel attempts on retrieved invitations errors
This commit is contained in:
parent
357ccf0b5b
commit
1179a6a6b7
2 changed files with 14 additions and 0 deletions
|
@ -133,9 +133,11 @@
|
|||
<td data-sort-value="{{ invitation.created_at|date:"U" }}" data-label="Date created">{{ invitation.created_at|date }} </td>
|
||||
<td data-label="Status">{{ invitation.status|title }}</td>
|
||||
<td>
|
||||
{% if invitation.status == invitation.DomainInvitationStatus.INVITED %}
|
||||
<form method="POST" action="{% url "invitation-delete" pk=invitation.id %}">
|
||||
{% csrf_token %}<input type="submit" class="usa-button--unstyled text-no-underline" value="Cancel">
|
||||
</form>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -822,6 +822,18 @@ class DomainAddUserView(DomainFormBaseView):
|
|||
class DomainInvitationDeleteView(SuccessMessageMixin, DomainInvitationPermissionDeleteView):
|
||||
object: DomainInvitation # workaround for type mismatch in DeleteView
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""Override post method in order to error in the case when the
|
||||
domain invitation status is RETRIEVED"""
|
||||
self.object = self.get_object()
|
||||
form = self.get_form()
|
||||
if form.is_valid() and self.object.status == self.object.DomainInvitationStatus.INVITED:
|
||||
return self.form_valid(form)
|
||||
else:
|
||||
# Produce an error message if the domain invatation status is RETRIEVED
|
||||
messages.error(request, f"Invitation to {self.object.email} has already been retrieved")
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse("domain-users", kwargs={"pk": self.object.domain.id})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue