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