mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-23 19:20:47 +02:00
changes
This commit is contained in:
parent
cb771f6208
commit
723bb0816a
5 changed files with 22 additions and 23 deletions
|
@ -321,9 +321,9 @@ urlpatterns = [
|
|||
name="user-profile",
|
||||
),
|
||||
path(
|
||||
"invitation/<int:pk>/delete",
|
||||
views.DomainInvitationDeleteView.as_view(http_method_names=["post"]),
|
||||
name="invitation-delete",
|
||||
"invitation/<int:pk>/cancel",
|
||||
views.DomainInvitationCancelView.as_view(http_method_names=["post"]),
|
||||
name="invitation-cancel",
|
||||
),
|
||||
path(
|
||||
"domain-request/<int:pk>/delete",
|
||||
|
|
|
@ -134,7 +134,7 @@
|
|||
<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 %}">
|
||||
<form method="POST" action="{% url "invitation-cancel" pk=invitation.id %}">
|
||||
{% csrf_token %}<input type="submit" class="usa-button--unstyled text-no-underline cursor-pointer" value="Cancel">
|
||||
</form>
|
||||
{% endif %}
|
||||
|
|
|
@ -200,7 +200,7 @@ def is_domain_subpage(path):
|
|||
"domain-users-add",
|
||||
"domain-request-delete",
|
||||
"domain-user-delete",
|
||||
"invitation-delete",
|
||||
"invitation-cancel",
|
||||
]
|
||||
return get_url_name(path) in url_names
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ from .domain import (
|
|||
DomainSecurityEmailView,
|
||||
DomainUsersView,
|
||||
DomainAddUserView,
|
||||
DomainInvitationDeleteView,
|
||||
DomainInvitationCancelView,
|
||||
DomainDeleteUserView,
|
||||
)
|
||||
|
|
|
@ -1054,26 +1054,26 @@ class DomainAddUserView(DomainFormBaseView):
|
|||
# # The order of the superclasses matters here. BaseDeleteView has a bug where the
|
||||
# # "form_valid" function does not call super, so it cannot use SuccessMessageMixin.
|
||||
# # The workaround is to use SuccessMessageMixin first.
|
||||
class DomainInvitationDeleteView(SuccessMessageMixin, DomainInvitationPermissionDeleteView):
|
||||
object: DomainInvitation # workaround for type mismatch in DeleteView
|
||||
# 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 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})
|
||||
# def get_success_url(self):
|
||||
# return reverse("domain-users", kwargs={"pk": self.object.domain.id})
|
||||
|
||||
def get_success_message(self, cleaned_data):
|
||||
return f"Canceled invitation to {self.object.email}."
|
||||
# def get_success_message(self, cleaned_data):
|
||||
# return f"Canceled invitation to {self.object.email}."
|
||||
|
||||
|
||||
class DomainInvitationCancelView(SuccessMessageMixin, DomainInvitationUpdateView):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue