mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-04 17:01:56 +02:00
Rewrite logic for "New domain request"
This commit is contained in:
parent
dff0ef8f3f
commit
964f40f0f7
2 changed files with 17 additions and 24 deletions
|
@ -125,13 +125,7 @@
|
|||
{% for application in domain_applications %}
|
||||
<tr>
|
||||
<th th scope="row" role="rowheader" data-label="Domain name">
|
||||
{% if application.requested_domain and application.requested_domain.name %}
|
||||
{{ application.requested_domain.name }}
|
||||
{% elif forloop.counter != 1 %}
|
||||
New domain request {{ forloop.counter }}
|
||||
{% else %}
|
||||
New domain request
|
||||
{% endif %}
|
||||
{{ application.requested_domain.name|default:"New domain request" }}
|
||||
</th>
|
||||
<td data-sort-value="{{ application.submission_date|date:"U" }}" data-label="Date submitted">
|
||||
{% if application.submission_date %}
|
||||
|
@ -147,21 +141,13 @@
|
|||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24">
|
||||
<use xlink:href="{%static 'img/sprite.svg'%}#edit"></use>
|
||||
</svg>
|
||||
{% if application.requested_domain and application.requested_domain.name %}
|
||||
Edit <span class="usa-sr-only">{{ application.requested_domain.name }}</span>
|
||||
{% else %}
|
||||
Edit <span class="usa-sr-only">New domain request {{ forloop.counter }}</span>
|
||||
{% endif %}
|
||||
Edit <span class="usa-sr-only">{{ application.requested_domain.name|default:"New domain request" }}</span>
|
||||
{% else %}
|
||||
<a href="{% url 'application-status' application.pk %}">
|
||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24">
|
||||
<use xlink:href="{%static 'img/sprite.svg'%}#settings"></use>
|
||||
</svg>
|
||||
{% if application.requested_domain and application.requested_domain.name %}
|
||||
Manage <span class="usa-sr-only">{{ application.requested_domain.name }}</span>
|
||||
{% else %}
|
||||
Manage <span class="usa-sr-only">New domain request {{ forloop.counter }}</span>
|
||||
{% endif %}
|
||||
Manage <span class="usa-sr-only">{{ application.requested_domain.name|default:"New domain request" }}</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
</td>
|
||||
|
@ -178,11 +164,7 @@
|
|||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24">
|
||||
<use xlink:href="{%static 'img/sprite.svg'%}#delete"></use>
|
||||
</svg>
|
||||
{% if application.requested_domain and application.requested_domain.name %}
|
||||
Delete <span class="usa-sr-only">{{ application.requested_domain.name }}</span>
|
||||
{% else %}
|
||||
Delete <span class="usa-sr-only">New domain request {{ forloop.counter }}</span>
|
||||
{% endif %}
|
||||
Delete <span class="usa-sr-only">{{ application.requested_domain.name|default:"New domain request" }}</span>
|
||||
</a>
|
||||
|
||||
<div
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
from registrar.models import DomainApplication, Domain, UserDomainRole
|
||||
from registrar.models.draft_domain import DraftDomain
|
||||
|
||||
|
||||
def index(request):
|
||||
"""This page is available to anyone without logging in."""
|
||||
context = {}
|
||||
if request.user.is_authenticated:
|
||||
applications = DomainApplication.objects.filter(creator=request.user)
|
||||
# Let's exclude the approved applications since our
|
||||
# domain_applications context will be used to populate
|
||||
# the active applications table
|
||||
context["domain_applications"] = applications.exclude(status="approved")
|
||||
applications = DomainApplication.objects.filter(creator=request.user).exclude(status="approved")
|
||||
|
||||
sorted_applications = applications.filter("-requested_domain__name")
|
||||
# Adds display logic for empty domain requests
|
||||
counter = 1
|
||||
for application in applications:
|
||||
if not application.requested_domain or not application.requested_domain.name:
|
||||
application.requested_domain = DraftDomain(name=f"New domain request {counter}")
|
||||
counter += 1
|
||||
|
||||
# Pass the final context to the application
|
||||
context["domain_applications"] = applications
|
||||
|
||||
user_domain_roles = UserDomainRole.objects.filter(user=request.user)
|
||||
domain_ids = user_domain_roles.values_list("domain_id", flat=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue