mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-12 20:49:41 +02:00
This is if we had wanted the cancel invitation by the status
This commit is contained in:
parent
77ddc6700a
commit
4b523a75ce
4 changed files with 27 additions and 50 deletions
|
@ -1533,44 +1533,12 @@ class DomainInvitationAdmin(BaseInvitationAdmin):
|
||||||
# # error.
|
# # error.
|
||||||
# readonly_fields = ["status"]
|
# readonly_fields = ["status"]
|
||||||
|
|
||||||
# Now it can be edited
|
readonly_fields = []
|
||||||
readonly_fields = ["status"]
|
|
||||||
|
|
||||||
autocomplete_fields = ["domain"]
|
autocomplete_fields = ["domain"]
|
||||||
|
|
||||||
change_form_template = "django/admin/domain_invitation_change_form.html"
|
change_form_template = "django/admin/domain_invitation_change_form.html"
|
||||||
|
|
||||||
# # Custom status filter within DomainInvitationAdmin
|
|
||||||
# class StatusListFilter(admin.SimpleListFilter):
|
|
||||||
# # custom filter for status field
|
|
||||||
|
|
||||||
# title = _("status")
|
|
||||||
# parameter_name = "status"
|
|
||||||
|
|
||||||
# def lookups(self, request, model_admin):
|
|
||||||
# # only return cancel as option
|
|
||||||
# return [
|
|
||||||
# ('canceled', _('Canceled')),
|
|
||||||
# ('invited', _('Invited')),
|
|
||||||
# ('retrieved', _('Retrieved')),
|
|
||||||
# ]
|
|
||||||
|
|
||||||
# def queryset(self, request, queryset):
|
|
||||||
# """Filter the queryset based on the selected status."""
|
|
||||||
# if self.value():
|
|
||||||
# return queryset.filter(status=self.value()) # Apply the filter based on the selected status
|
|
||||||
# return queryset
|
|
||||||
|
|
||||||
# list_filter = (StatusListFilter,) # Apply the custom filter to the list view
|
|
||||||
|
|
||||||
# # Select domain invitations to change -> Domain invitations
|
|
||||||
# def changelist_view(self, request, extra_context=None):
|
|
||||||
# if extra_context is None:
|
|
||||||
# extra_context = {}
|
|
||||||
# extra_context["tabtitle"] = "Domain invitations"
|
|
||||||
# # Get the filtered values
|
|
||||||
# return super().changelist_view(request, extra_context=extra_context)
|
|
||||||
|
|
||||||
def save_model(self, request, obj, form, change):
|
def save_model(self, request, obj, form, change):
|
||||||
"""
|
"""
|
||||||
Override the save_model method.
|
Override the save_model method.
|
||||||
|
@ -1580,22 +1548,6 @@ class DomainInvitationAdmin(BaseInvitationAdmin):
|
||||||
just continue to create the invitation.
|
just continue to create the invitation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# print("***** IN SAVE_MODEL, OUTSIDE OF CHANGE")
|
|
||||||
|
|
||||||
# # If there is a change and it's related to status, look for canceled
|
|
||||||
# if change and "status" in form.changed_data:
|
|
||||||
# print("********* DO WE COME INTO THE CHANGE SECTION")
|
|
||||||
# if obj.status == DomainInvitation.DomainInvitationStatus.CANCELED:
|
|
||||||
# # Call the transition method to change the status
|
|
||||||
# obj.cancel_invitation()
|
|
||||||
# messages.success(request, f"Invitation for {obj.email} has been canceled.")
|
|
||||||
# return super().save_model(request, obj, form, change)
|
|
||||||
|
|
||||||
# # if invited/retrieved dont alow manual changes
|
|
||||||
# if obj.status not in [DomainInvitation.DomainInvitationStatus.INVITED, DomainInvitation.DomainInvitationStatus.RETRIEVED]:
|
|
||||||
# messages.error(request, "You cannot manually set the status to anything other than 'invited' or 'retrieved'.")
|
|
||||||
# return
|
|
||||||
|
|
||||||
if not change:
|
if not change:
|
||||||
domain = obj.domain
|
domain = obj.domain
|
||||||
domain_org = getattr(domain.domain_info, "portfolio", None)
|
domain_org = getattr(domain.domain_info, "portfolio", None)
|
||||||
|
|
22
src/registrar/templates/admin/status_with_clipboard.html
Normal file
22
src/registrar/templates/admin/status_with_clipboard.html
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
<div class="admin-icon-group">
|
||||||
|
<span id="status-field">{{ field.value | capfirst }}</span>
|
||||||
|
|
||||||
|
<input aria-hidden="true" class="display-none" value="">
|
||||||
|
<button
|
||||||
|
class="usa-button--dja usa-button usa-button__small-text usa-button--unstyled padding-left-1 usa-button--icon copy-to-clipboard"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<div class="no-outline-on-click">
|
||||||
|
<svg
|
||||||
|
class="usa-icon"
|
||||||
|
>
|
||||||
|
<use aria-hidden="true" xlink:href="{%static 'img/sprite.svg'%}#highlight_off"></use>
|
||||||
|
</svg>
|
||||||
|
<!-- the span is targeted in JS, do not remove -->
|
||||||
|
<span>Cancel invitation</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
|
@ -11,4 +11,4 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -7,7 +7,10 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
{% block field_other %}
|
{% block field_other %}
|
||||||
{% if field.field.name == "email" %}
|
{% if field.field.name == "email" %}
|
||||||
{% include "admin/input_with_clipboard.html" with field=field.field %}
|
{% include "admin/input_with_clipboard.html" with field=field.field %}
|
||||||
|
{% elif field.field.name == "status" %}
|
||||||
|
{% include "admin/status_with_clipboard.html" with field=field.field %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock field_other %}
|
{% endblock field_other %}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue