mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-31 23:16:36 +02:00
changes to domain request admin form
This commit is contained in:
parent
16bcae0dc2
commit
996d8eaccf
3 changed files with 84 additions and 8 deletions
|
@ -323,9 +323,10 @@ class DomainRequestAdminForm(forms.ModelForm):
|
||||||
# only set the available transitions if the user is not restricted
|
# only set the available transitions if the user is not restricted
|
||||||
# from editing the domain request; otherwise, the form will be
|
# from editing the domain request; otherwise, the form will be
|
||||||
# readonly and the status field will not have a widget
|
# readonly and the status field will not have a widget
|
||||||
if not domain_request.creator.is_restricted():
|
if not domain_request.creator.is_restricted() and "status" in self.fields:
|
||||||
self.fields["status"].widget.choices = available_transitions
|
self.fields["status"].widget.choices = available_transitions
|
||||||
|
|
||||||
|
|
||||||
def get_custom_field_transitions(self, instance, field):
|
def get_custom_field_transitions(self, instance, field):
|
||||||
"""Custom implementation of get_available_FIELD_transitions
|
"""Custom implementation of get_available_FIELD_transitions
|
||||||
in the FSM. Allows us to still display fields filtered out by a condition."""
|
in the FSM. Allows us to still display fields filtered out by a condition."""
|
||||||
|
@ -1295,7 +1296,7 @@ class SeniorOfficialAdmin(ListHeaderAdmin):
|
||||||
if obj:
|
if obj:
|
||||||
if request.user.groups.filter(name="omb_analysts_group").exists():
|
if request.user.groups.filter(name="omb_analysts_group").exists():
|
||||||
return obj.federal_agency and obj.federal_agency.federal_type == BranchChoices.EXECUTIVE
|
return obj.federal_agency and obj.federal_agency.federal_type == BranchChoices.EXECUTIVE
|
||||||
return super().has_delete_permisssion(request, obj)
|
return super().has_delete_permission(request, obj)
|
||||||
|
|
||||||
|
|
||||||
class WebsiteResource(resources.ModelResource):
|
class WebsiteResource(resources.ModelResource):
|
||||||
|
@ -2749,6 +2750,53 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportRegistrarModelAdmin):
|
||||||
"cisa_representative_email",
|
"cisa_representative_email",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Read only that we'll leverage for OMB Analysts
|
||||||
|
omb_analyst_readonly_fields = [
|
||||||
|
"federal_agency",
|
||||||
|
"creator",
|
||||||
|
"about_your_organization",
|
||||||
|
"requested_domain",
|
||||||
|
"approved_domain",
|
||||||
|
"alternative_domains",
|
||||||
|
"purpose",
|
||||||
|
"no_other_contacts_rationale",
|
||||||
|
"anything_else",
|
||||||
|
"is_policy_acknowledged",
|
||||||
|
"cisa_representative_first_name",
|
||||||
|
"cisa_representative_last_name",
|
||||||
|
"cisa_representative_email",
|
||||||
|
"status",
|
||||||
|
"investigator",
|
||||||
|
"notes",
|
||||||
|
"senior_official",
|
||||||
|
"organization_type",
|
||||||
|
"organization_name",
|
||||||
|
"state_territory",
|
||||||
|
"address_line1",
|
||||||
|
"address_line2",
|
||||||
|
"city",
|
||||||
|
"zipcode",
|
||||||
|
"urbanization",
|
||||||
|
"portfolio_organization_type",
|
||||||
|
"portfolio_federal_type",
|
||||||
|
"portfolio_organization_name",
|
||||||
|
"portfolio_federal_agency",
|
||||||
|
"portfolio_state_territory",
|
||||||
|
"portfolio_address_line1",
|
||||||
|
"portfolio_address_line2",
|
||||||
|
"portfolio_city",
|
||||||
|
"portfolio_zipcode",
|
||||||
|
"portfolio_urbanization",
|
||||||
|
"is_election_board",
|
||||||
|
"organization_type",
|
||||||
|
"federal_type",
|
||||||
|
"federal_agency",
|
||||||
|
"tribe_name",
|
||||||
|
"federally_recognized_tribe",
|
||||||
|
"state_recognized_tribe",
|
||||||
|
"about_your_organization",
|
||||||
|
]
|
||||||
|
|
||||||
autocomplete_fields = [
|
autocomplete_fields = [
|
||||||
"approved_domain",
|
"approved_domain",
|
||||||
"requested_domain",
|
"requested_domain",
|
||||||
|
@ -2990,6 +3038,10 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportRegistrarModelAdmin):
|
||||||
|
|
||||||
if request.user.has_perm("registrar.full_access_permission"):
|
if request.user.has_perm("registrar.full_access_permission"):
|
||||||
return readonly_fields
|
return readonly_fields
|
||||||
|
# Return restrictive Read-only fields for OMB analysts
|
||||||
|
if request.user.groups.filter(name="omb_analysts_group").exists():
|
||||||
|
readonly_fields.extend([field for field in self.omb_analyst_readonly_fields])
|
||||||
|
return readonly_fields
|
||||||
# Return restrictive Read-only fields for analysts and
|
# Return restrictive Read-only fields for analysts and
|
||||||
# users who might not belong to groups
|
# users who might not belong to groups
|
||||||
readonly_fields.extend([field for field in self.analyst_readonly_fields])
|
readonly_fields.extend([field for field in self.analyst_readonly_fields])
|
||||||
|
@ -3254,6 +3306,14 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportRegistrarModelAdmin):
|
||||||
|
|
||||||
return combined_queryset, use_distinct
|
return combined_queryset, use_distinct
|
||||||
|
|
||||||
|
def get_form(self, request, obj=None, **kwargs):
|
||||||
|
"""Pass the 'is_omb_analyst' attribute to the form."""
|
||||||
|
form = super().get_form(request, obj, **kwargs)
|
||||||
|
|
||||||
|
# Store attribute in the form for template access
|
||||||
|
form.show_contact_as_plain_text = request.user.groups.filter(name="omb_analysts_group").exists()
|
||||||
|
|
||||||
|
return form
|
||||||
|
|
||||||
class TransitionDomainAdmin(ListHeaderAdmin):
|
class TransitionDomainAdmin(ListHeaderAdmin):
|
||||||
"""Custom transition domain admin class."""
|
"""Custom transition domain admin class."""
|
||||||
|
@ -4556,7 +4616,7 @@ class PortfolioAdmin(ListHeaderAdmin):
|
||||||
if obj:
|
if obj:
|
||||||
if request.user.groups.filter(name="omb_analysts_group").exists():
|
if request.user.groups.filter(name="omb_analysts_group").exists():
|
||||||
return obj.federal_type == BranchChoices.EXECUTIVE
|
return obj.federal_type == BranchChoices.EXECUTIVE
|
||||||
return super().has_delete_permisssion(request, obj)
|
return super().has_delete_permission(request, obj)
|
||||||
|
|
||||||
def change_view(self, request, object_id, form_url="", extra_context=None):
|
def change_view(self, request, object_id, form_url="", extra_context=None):
|
||||||
"""Add related suborganizations and domain groups.
|
"""Add related suborganizations and domain groups.
|
||||||
|
@ -4657,7 +4717,7 @@ class FederalAgencyAdmin(ListHeaderAdmin, ImportExportRegistrarModelAdmin):
|
||||||
if obj:
|
if obj:
|
||||||
if request.user.groups.filter(name="omb_analysts_group").exists():
|
if request.user.groups.filter(name="omb_analysts_group").exists():
|
||||||
return obj.federal_type == BranchChoices.EXECUTIVE
|
return obj.federal_type == BranchChoices.EXECUTIVE
|
||||||
return super().has_delete_permisssion(request, obj)
|
return super().has_delete_permission(request, obj)
|
||||||
|
|
||||||
|
|
||||||
class UserGroupAdmin(AuditedAdmin):
|
class UserGroupAdmin(AuditedAdmin):
|
||||||
|
@ -4797,7 +4857,7 @@ class SuborganizationAdmin(ListHeaderAdmin, ImportExportRegistrarModelAdmin):
|
||||||
if obj:
|
if obj:
|
||||||
if request.user.groups.filter(name="omb_analysts_group").exists():
|
if request.user.groups.filter(name="omb_analysts_group").exists():
|
||||||
return obj.portfolio and obj.portfolio.federal_type == BranchChoices.EXECUTIVE
|
return obj.portfolio and obj.portfolio.federal_type == BranchChoices.EXECUTIVE
|
||||||
return super().has_delete_permisssion(request, obj)
|
return super().has_delete_permission(request, obj)
|
||||||
|
|
||||||
|
|
||||||
class AllowedEmailAdmin(ListHeaderAdmin):
|
class AllowedEmailAdmin(ListHeaderAdmin):
|
||||||
|
|
|
@ -6,7 +6,11 @@
|
||||||
|
|
||||||
{% if show_formatted_name %}
|
{% if show_formatted_name %}
|
||||||
{% if user.get_formatted_name %}
|
{% if user.get_formatted_name %}
|
||||||
<a class="contact_info_name" href="{% url 'admin:registrar_contact_change' user.id %}">{{ user.get_formatted_name }}</a>
|
{% if adminform.form.show_contact_as_plain_text %}
|
||||||
|
{{ user.get_formatted_name }}
|
||||||
|
{% else %}
|
||||||
|
<a class="contact_info_name" href="{% url 'admin:registrar_contact_change' user.id %}">{{ user.get_formatted_name }}</a>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
None
|
None
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -69,7 +69,11 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
{% elif field.field.name == "portfolio_senior_official" %}
|
{% elif field.field.name == "portfolio_senior_official" %}
|
||||||
<div class="readonly">
|
<div class="readonly">
|
||||||
{% if original_object.portfolio.senior_official %}
|
{% if original_object.portfolio.senior_official %}
|
||||||
<a href="{% url 'admin:registrar_seniorofficial_change' original_object.portfolio.senior_official.id %}">{{ field.contents }}</a>
|
{% if adminform.form.show_contact_as_plain_text %}
|
||||||
|
{{ field.contents|striptags }}
|
||||||
|
{% else %}
|
||||||
|
<a href="{% url 'admin:registrar_seniorofficial_change' original_object.portfolio.senior_official.id %}">{{ field.contents }}</a>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
No senior official found.<br>
|
No senior official found.<br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -78,7 +82,11 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
{% if all_contacts.count > 2 %}
|
{% if all_contacts.count > 2 %}
|
||||||
<div class="readonly">
|
<div class="readonly">
|
||||||
{% for contact in all_contacts %}
|
{% for contact in all_contacts %}
|
||||||
<a href="{% url 'admin:registrar_contact_change' contact.id %}">{{ contact.get_formatted_name }}</a>{% if not forloop.last %}, {% endif %}
|
{% if adminform.form.show_contact_as_plain_text %}
|
||||||
|
{{ contact.get_formatted_name }}{% if not forloop.last %}, {% endif %}
|
||||||
|
{% else %}
|
||||||
|
<a href="{% url 'admin:registrar_contact_change' contact.id %}">{{ contact.get_formatted_name }}</a>{% if not forloop.last %}, {% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -153,6 +161,10 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
<p>No additional members found.</p>
|
<p>No additional members found.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% elif field.field.name == "creator" and adminform.form.show_contact_as_plain_text %}
|
||||||
|
<div class="readonly">{{ field.contents|striptags }}</div>
|
||||||
|
{% elif field.field.name == "senior_official" and adminform.form.show_contact_as_plain_text %}
|
||||||
|
<div class="readonly">{{ field.contents|striptags }}</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="readonly">{{ field.contents }}</div>
|
<div class="readonly">{{ field.contents }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue