From 2ee9a8f32daab5bb01c724b5c1d69082654c8aef Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Wed, 17 Jan 2024 16:32:02 -0500 Subject: [PATCH] Remove is_complete and do the test and string concat in template instead --- .../0063_draftdomain_is_complete.py | 17 -------------- src/registrar/models/draft_domain.py | 2 -- src/registrar/templates/home.html | 23 +++++++++++++++++-- src/registrar/views/index.py | 8 +------ 4 files changed, 22 insertions(+), 28 deletions(-) delete mode 100644 src/registrar/migrations/0063_draftdomain_is_complete.py diff --git a/src/registrar/migrations/0063_draftdomain_is_complete.py b/src/registrar/migrations/0063_draftdomain_is_complete.py deleted file mode 100644 index d17e59400..000000000 --- a/src/registrar/migrations/0063_draftdomain_is_complete.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 4.2.7 on 2024-01-16 20:35 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("registrar", "0062_alter_host_name"), - ] - - operations = [ - migrations.AddField( - model_name="draftdomain", - name="is_complete", - field=models.BooleanField(default=True, help_text="Determines if this Draft is complete or not"), - ), - ] diff --git a/src/registrar/models/draft_domain.py b/src/registrar/models/draft_domain.py index 2aa2cdbfb..fc70a18f3 100644 --- a/src/registrar/models/draft_domain.py +++ b/src/registrar/models/draft_domain.py @@ -20,5 +20,3 @@ class DraftDomain(TimeStampedModel, DomainHelper): default=None, # prevent saving without a value help_text="Fully qualified domain name", ) - - is_complete = models.BooleanField(default=True, help_text="Determines if this Draft is complete or not") diff --git a/src/registrar/templates/home.html b/src/registrar/templates/home.html index 1ab4a135e..5bda944c4 100644 --- a/src/registrar/templates/home.html +++ b/src/registrar/templates/home.html @@ -124,7 +124,7 @@ {% for application in domain_applications %} - {% if application.requested_domain is None or not application.requested_domain.is_complete %} + {% if application.requested_domain is None %} New domain request
({{ application.created_at }}) @@ -181,7 +181,26 @@ data-force-action >
- {% include 'includes/modal.html' with modal_heading="Are you sure you want to delete "|add:application.requested_domain.name|add:"?" modal_description="This will remove the domain request from the .gov registrar. This action cannot be undone." modal_button=modal_button|safe %} + {% if application.requested_domain is None %} + {% with prefix="Are you sure you want to delete New domain request " %} + {% if application.created_at %} + {% with formatted_date=application.created_at|date:"DATETIME_FORMAT" %} + {% with modal_heading=prefix|add:formatted_date %} + {% include 'includes/modal.html' with modal_heading=modal_heading modal_description="This will remove the domain request from the .gov registrar. This action cannot be undone." modal_button=modal_button|safe %} + {% endwith %} + {% endwith %} + {% else %} + {# Handle the case when application.created_at is not available or empty #} + {% with modal_heading=prefix %} + {% include 'includes/modal.html' with modal_heading=modal_heading modal_description="This will remove the domain request from the .gov registrar. This action cannot be undone." modal_button=modal_button|safe %} + {% endwith %} + {% endif %} + {% endwith %} + {% else %} + {% with modal_heading="Are you sure you want to delete "|add:application.requested_domain.name|add:"?" %} + {% include 'includes/modal.html' with modal_heading=modal_heading modal_description="This will remove the domain request from the .gov registrar. This action cannot be undone." modal_button=modal_button|safe %} + {% endwith %} + {% endif %}
{% endif %} diff --git a/src/registrar/views/index.py b/src/registrar/views/index.py index f9dcaa253..b98154a23 100644 --- a/src/registrar/views/index.py +++ b/src/registrar/views/index.py @@ -48,13 +48,7 @@ def _get_applications(request): # Create a placeholder DraftDomain for each incomplete draft valid_statuses = [DomainApplication.ApplicationStatus.STARTED, DomainApplication.ApplicationStatus.WITHDRAWN] deletable_applications = applications.filter(status__in=valid_statuses) - for application in applications: - if application in deletable_applications and application.requested_domain is None: - created_at = application.created_at.strftime("%b. %d, %Y, %I:%M %p UTC") - _name = f"New domain request ({created_at})" - default_draft_domain = DraftDomain(name=_name, is_complete=False) - - application.requested_domain = default_draft_domain + return (applications, deletable_applications)