Fix domain request button

This commit is contained in:
zandercymatics 2024-06-06 09:06:30 -06:00
parent d870127eb3
commit 40fd46a2bb
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
3 changed files with 32 additions and 14 deletions

View file

@ -761,3 +761,10 @@ div.dja__model-description{
.usa-summary-box h3 { .usa-summary-box h3 {
color: #{$dhs-blue-60}; color: #{$dhs-blue-60};
} }
.analytics-button-group {
flex-wrap: wrap;
a {
min-width: 160px !important;
}
}

View file

@ -27,36 +27,35 @@
<div class="module height-full"> <div class="module height-full">
<h2>Current domains</h2> <h2>Current domains</h2>
<div class="padding-top-2 padding-x-2"> <div class="padding-top-2 padding-x-2">
<ul class="usa-button-group"> <ul class="usa-button-group analytics-button-group">
<li class="usa-button-group__item"> <li class="usa-button-group__item">
<a href="{% url 'export_data_type' %}" class="button" role="button"> <a href="{% url 'export_data_type' %}" class="button text-no-wrap" role="button">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24"> <svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
<use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use> <use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use>
</svg><span class="margin-left-05">All domain metadata</span> </svg><span class="margin-left-05">All domain metadata</span>
</a> </a>
</li> </li>
<li class="usa-button-group__item"> <li class="usa-button-group__item">
<a href="{% url 'export_data_full' %}" class="button" role="button"> <a href="{% url 'export_data_full' %}" class="button text-no-wrap" role="button">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24"> <svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
<use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use> <use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use>
</svg><span class="margin-left-05">Current full</span> </svg><span class="margin-left-05">Current full</span>
</a> </a>
</li> </li>
<li class="usa-button-group__item"> <li class="usa-button-group__item">
<a href="{% url 'export_data_federal' %}" class="button" role="button"> <a href="{% url 'export_data_federal' %}" class="button text-no-wrap" role="button">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24"> <svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
<use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use> <use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use>
</svg><span class="margin-left-05">Current federal</span> </svg><span class="margin-left-05">Current federal</span>
</a> </a>
</li> </li>
{# TODO: move this and rename it #}
<li class="usa-button-group__item"> <li class="usa-button-group__item">
<a href="{% url 'export_data_domain_requests_full' %}" class="button" role="button"> <a href="{% url 'export_data_domain_requests_full' %}" class="button text-no-wrap" role="button">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24"> <svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
<use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use> <use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use>
</svg><span class="margin-left-05">Current domain request full</span> </svg><span class="margin-left-05">All domain requests</span>
</a> </a>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>

View file

@ -15,6 +15,7 @@ from django.utils import timezone
from django.core.paginator import Paginator from django.core.paginator import Paginator
from django.db.models.functions import Concat, Coalesce from django.db.models.functions import Concat, Coalesce
from django.contrib.postgres.aggregates import StringAgg from django.contrib.postgres.aggregates import StringAgg
from registrar.templatetags.custom_filters import get_region
from registrar.utility.enums import DefaultEmail from registrar.utility.enums import DefaultEmail
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -750,7 +751,7 @@ class DomainRequestExport:
# create a dictionary of fields which can be included in output # create a dictionary of fields which can be included in output
FIELDS = { FIELDS = {
"Domain request": request.get("requested_domain_name"), "Domain request": request.get("requested_domain_name"),
"Submitted at": request.get("submission_date"), # TODO - different format? "Submitted at": request.get("submission_date"),
"Status": request.get("status_display"), "Status": request.get("status_display"),
"Domain type": request.get("domain_type"), "Domain type": request.get("domain_type"),
"Federal type": request.get("human_readable_federal_type"), "Federal type": request.get("human_readable_federal_type"),
@ -759,7 +760,7 @@ class DomainRequestExport:
"Election office": request.get("human_readable_election_board"), "Election office": request.get("human_readable_election_board"),
"City": request.get("city"), "City": request.get("city"),
"State/territory": request.get("state_territory"), "State/territory": request.get("state_territory"),
"Region": None, # TODO - what is this field? "Region": request.get("region"),
# Creator # Creator
"Creator first name": request.get("creator__first_name", ""), "Creator first name": request.get("creator__first_name", ""),
"Creator last name": request.get("creator__last_name", ""), "Creator last name": request.get("creator__last_name", ""),
@ -963,6 +964,8 @@ class DomainRequestExport:
"federal_type", "federal_type",
) )
# We can't natively call python functions from the ORM.
# Thus in any place where we do that, we have to handle it here.
for request in requests_dict: for request in requests_dict:
# Handle the domain_type field. Defaults to the wrong format. # Handle the domain_type field. Defaults to the wrong format.
org_type = request.get("generic_org_type") org_type = request.get("generic_org_type")
@ -980,6 +983,11 @@ class DomainRequestExport:
if status: if status:
request["status_display"] = DomainRequest.DomainRequestStatus.get_status_label(status) request["status_display"] = DomainRequest.DomainRequestStatus.get_status_label(status)
# Handle the region field.
state_territory = request.get("state_territory")
if state_territory:
request["region"] = get_region(state_territory)
return requests_dict return requests_dict
# ============================================================= # # ============================================================= #
@ -1018,17 +1026,21 @@ class DomainRequestExport:
""" """
# TODO this should be replaced with cisa_representative_first_name and cisa_representative_last_name # TODO this should be replaced with cisa_representative_first_name and cisa_representative_last_name
# When that PR gets merged
additional_details_query = Case( additional_details_query = Case(
# Check if either cisa_representative_email or anything_else is not null
# TODO - touch up on this
When( When(
cisa_representative_email__isnull=False, cisa_representative_email__isnull=False,
anything_else__isnull=False,
then=Concat(F("cisa_representative_email"), Value(delimiter), F("anything_else")), then=Concat(F("cisa_representative_email"), Value(delimiter), F("anything_else")),
), ),
When( When(
cisa_representative_email__isnull=True,
anything_else__isnull=False, anything_else__isnull=False,
then=Concat(F("cisa_representative_email"), Value(delimiter), F("anything_else")), then=F("anything_else"),
),
When(
cisa_representative_email__isnull=False,
anything_else__isnull=True,
then=F("cisa_representative_email"),
), ),
default=Value(default_message), default=Value(default_message),
output_field=CharField(), output_field=CharField(),