PR suggestions

This commit is contained in:
zandercymatics 2024-03-26 13:21:40 -06:00
parent 55fd53fb56
commit a70214e467
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
3 changed files with 88 additions and 43 deletions

View file

@ -910,6 +910,9 @@ class DomainInformationAdmin(ListHeaderAdmin):
), ),
] ]
# Readonly fields for analysts and superusers
readonly_fields = ("other_contacts",)
# Read only that we'll leverage for CISA Analysts # Read only that we'll leverage for CISA Analysts
analyst_readonly_fields = [ analyst_readonly_fields = [
"creator", "creator",
@ -1120,6 +1123,9 @@ class DomainRequestAdmin(ListHeaderAdmin):
), ),
] ]
# Readonly fields for analysts and superusers
readonly_fields = ("other_contacts", "current_websites")
# Read only that we'll leverage for CISA Analysts # Read only that we'll leverage for CISA Analysts
analyst_readonly_fields = [ analyst_readonly_fields = [
"creator", "creator",

View file

@ -1,47 +1,67 @@
{% load i18n static %} {% load i18n static %}
<table class="dja-user-detail-table margin-top-1" {% if field_name %} id="id_detail_table__{{field_name}}" {% endif %}> <table class="dja-user-detail-table" {% if field_name %} id="id_detail_table__{{field_name}}" {% endif %}>
{% if show_table_details %}
<thead> <thead>
<tr> <tr>
<th colspan="2">Contact details</th> <th colspan="2">Contact details</th>
<tr> <tr>
</thead> </thead>
{% endif %}
{% if user.title or user.contact.title or user.email or user.contact.email or user.phone or user.contact.phone %}
<tbody> <tbody>
<tr> <tr>
<th scope="row">Title</th> {% if show_table_details %}
<th class="{% if no_title_top_padding %}padding-top-0{% endif %}" scope="row">Title</th>
{% endif %}
{% if user.title or user.contact.title %} {% if user.title or user.contact.title %}
{% if user.contact.title %} {% if user.contact.title %}
<td>{{ user.contact.title }}</td> <td class="{% if no_title_top_padding %}padding-top-0{% endif %} padding-left-0">{{ user.contact.title }}</td>
{% else %} {% else %}
<td>{{ user.title }}</td> <td class="{% if no_title_top_padding %}padding-top-0{% endif %} padding-left-0">{{ user.title }}</td>
{% endif %} {% endif %}
{% else %} {% else %}
<td>Nothing found</td> <td class="{% if no_title_top_padding %}padding-top-0{% endif %} padding-left-0">None</td>
{% endif %} {% endif %}
</tr> </tr>
<tr> <tr>
<th class="padding-top-0" scope="row">Email</th> {% if show_table_details %}
<th class="padding-top-0 padding-left-0" scope="row">Email</th>
{% endif %}
{% if user.email or user.contact.email %} {% if user.email or user.contact.email %}
{% if user.contact.email %} {% if user.contact.email %}
<td class="padding-top-0">{{ user.contact.email }}</td> <td class="padding-top-0 padding-left-0">{{ user.contact.email }}</td>
{% else %} {% else %}
<td class="padding-top-0">{{ user.email }}</td> <td class="padding-top-0 padding-left-0">{{ user.email }}</td>
{% endif %} {% endif %}
{% else %} {% else %}
<td class="padding-top-0">Nothing found</td> <td class="padding-top-0 padding-left-0">None</td>
{% endif %} {% endif %}
</tr> </tr>
<tr> <tr>
<th class="padding-top-0" scope="row">Phone</th> {% if show_table_details %}
<th class="padding-top-0 padding-left-0" scope="row">Phone</th>
{% endif %}
{% if user.phone or user.contact.phone %} {% if user.phone or user.contact.phone %}
{% if user.contact.phone %} {% if user.contact.phone %}
<td class="padding-top-0">{{ user.contact.phone }}</td> <td class="padding-top-0 padding-left-0">{{ user.contact.phone }}</td>
{% else %} {% else %}
<td class="padding-top-0">{{ user.phone }}</td> <td class="padding-top-0 padding-left-0">{{ user.phone }}</td>
{% endif %} {% endif %}
{% else %} {% else %}
<td class="padding-top-0">Nothing found</td> <td class="padding-top-0 padding-left-0">None</td>
{% endif %} {% endif %}
</tr> </tr>
</tbody> </tbody>
{% else %}
<tbody>
<tr>
<td class="padding-left-0">No additional contact information found.</td>
</tr>
</tbody>
{% endif %}
</table> </table>

View file

@ -20,9 +20,17 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
This ONLY applies to analysts. For superusers, its business as usual. This ONLY applies to analysts. For superusers, its business as usual.
{% endcomment %} {% endcomment %}
{% for website in field.contents|split:", " %} <div class="readonly">
{% with total_websites=field.contents|split:", " %}
{% for website in total_websites %}
<a href="{{ website }}" class="padding-top-1 current-website__{{forloop.counter}}">{{ website }}</a>{% if not forloop.last %}, {% endif %} <a href="{{ website }}" class="padding-top-1 current-website__{{forloop.counter}}">{{ website }}</a>{% if not forloop.last %}, {% endif %}
{# Acts as a <br> #}
{% if total_websites|length < 5 %}
<div class="display-block margin-top-1"></div>
{% endif %}
{% endfor %} {% endfor %}
{% endwith %}
</div>
{% else %} {% else %}
<div class="readonly">{{ field.contents }}</div> <div class="readonly">{{ field.contents }}</div>
{% endif %} {% endif %}
@ -32,19 +40,28 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
{% if field.field.name == "creator" %} {% if field.field.name == "creator" %}
<div class="flex-container"> <div class="flex-container">
<label aria-label="Creator contact details"></label> <label aria-label="Creator contact details"></label>
{% include "django/admin/includes/contact_detail_table.html" with user=original.creator field_name="creator" %} {% include "django/admin/includes/contact_detail_table.html" with user=original.creator field_name="creator" no_title_top_padding=field.is_readonly %}
</div> </div>
{% elif field.field.name == "submitter" %} {% elif field.field.name == "submitter" %}
<div class="flex-container"> <div class="flex-container">
<label aria-label="Submitter contact details"></label> <label aria-label="Submitter contact details"></label>
{% include "django/admin/includes/contact_detail_table.html" with user=original.submitter field_name="submitter" %} {% include "django/admin/includes/contact_detail_table.html" with user=original.submitter field_name="submitter" no_title_top_padding=field.is_readonly %}
</div> </div>
{% elif field.field.name == "authorizing_official" %} {% elif field.field.name == "authorizing_official" %}
<div class="flex-container"> <div class="flex-container">
<label aria-label="Authorizing official contact details"></label> <label aria-label="Authorizing official contact details"></label>
{% include "django/admin/includes/contact_detail_table.html" with user=original.authorizing_official field_name="authorizing_official" %} {% include "django/admin/includes/contact_detail_table.html" with user=original.authorizing_official field_name="authorizing_official" no_title_top_padding=field.is_readonly %}
</div> </div>
{% elif field.field.name == "other_contacts" and original.other_contacts.all %} {% elif field.field.name == "other_contacts" and original.other_contacts.all %}
{% with all_contacts=original.other_contacts.all %}
{% if all_contacts.count == 1 %}
{% for contact in all_contacts %}
<div class="flex-container">
<label aria-label="Other contact details"></label>
{% include "django/admin/includes/contact_detail_table.html" with user=contact field_name="other_contact" no_title_top_padding=field.is_readonly %}
</div>
{% endfor %}
{% else %}
<details class="margin-top-1 dja-detail-table" aria-role="button"> <details class="margin-top-1 dja-detail-table" aria-role="button">
<summary class="padding-1 padding-left-0 dja-details-summary">Details</summary> <summary class="padding-1 padding-left-0 dja-details-summary">Details</summary>
<div class="grid-container margin-left-0 padding-left-0 padding-right-0 dja-details-contents"> <div class="grid-container margin-left-0 padding-left-0 padding-right-0 dja-details-contents">
@ -55,7 +72,7 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
<tr> <tr>
</thead> </thead>
<tbody> <tbody>
{% for contact in original.other_contacts.all %} {% for contact in all_contacts %}
{% comment %} {% comment %}
Since we can't get the id from field, we can embed this information here. Since we can't get the id from field, we can embed this information here.
Then we can link these two fields using javascript. Then we can link these two fields using javascript.
@ -72,4 +89,6 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
</div> </div>
</details> </details>
{% endif %} {% endif %}
{% endwith %}
{% endif %}
{% endblock after_help_text %} {% endblock after_help_text %}