Linting and fix unit test

This commit is contained in:
zandercymatics 2024-01-16 08:52:03 -07:00
parent c949566744
commit a3f78e2ac7
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
3 changed files with 11 additions and 16 deletions

View file

@ -26,12 +26,8 @@ class DraftDomain(TimeStampedModel, DomainHelper):
help_text="The draft number in the event a user doesn't save at this stage", help_text="The draft number in the event a user doesn't save at this stage",
) )
is_incomplete = models.BooleanField( is_incomplete = models.BooleanField(default=False, help_text="Determines if this Draft is complete or not")
default=False,
help_text="Determines if this Draft is complete or not"
)
def get_default_request_name(self): def get_default_request_name(self):
"""Returns the draft name that would be used for applications if no name exists""" """Returns the draft name that would be used for applications if no name exists"""
return f"New domain request {self.draft_number}" return f"New domain request {self.draft_number}"

View file

@ -1,6 +1,4 @@
import logging import logging
import re
from typing import List
from django.db.models import Q from django.db.models import Q
from django.http import Http404, HttpResponse, HttpResponseRedirect from django.http import Http404, HttpResponse, HttpResponseRedirect
@ -143,7 +141,7 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
return self._application return self._application
except DomainApplication.DoesNotExist: except DomainApplication.DoesNotExist:
logger.debug("Application id %s did not have a DomainApplication" % id) logger.debug("Application id %s did not have a DomainApplication" % id)
# TODO - revert back to using draft_name # TODO - revert back to using draft_name
draft_domain = self._create_default_draft_domain() draft_domain = self._create_default_draft_domain()
self._application = DomainApplication.objects.create( self._application = DomainApplication.objects.create(
@ -166,9 +164,11 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
name_field = "requested_domain__name" name_field = "requested_domain__name"
incomplete_drafts = existing_applications.exclude(requested_domain=None).filter( incomplete_drafts = (
requested_domain__name__icontains=default_draft_text existing_applications.exclude(requested_domain=None)
).order_by(name_field) .filter(requested_domain__name__icontains=default_draft_text)
.order_by(name_field)
)
incomplete_draft_names = incomplete_drafts.values_list(name_field, flat=True) incomplete_draft_names = incomplete_drafts.values_list(name_field, flat=True)
@ -178,9 +178,9 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
if application.requested_domain is not None and application.requested_domain.name is not None: if application.requested_domain is not None and application.requested_domain.name is not None:
name = application.requested_domain.name name = application.requested_domain.name
# If we already have a list of draft numbers, base the # If we already have a list of draft numbers, base the
# subsequent number off of the last numbered field. # subsequent number off of the last numbered field.
# This is to avoid a scenario in which drafts 1, 2, 3 and exist # This is to avoid a scenario in which drafts 1, 2, 3 and exist
# and 2 is deleted - meaning we would get two duplicate "3"s if we added another # and 2 is deleted - meaning we would get two duplicate "3"s if we added another
if name in incomplete_draft_names: if name in incomplete_draft_names:
# Get the last numbered draft # Get the last numbered draft
@ -403,7 +403,7 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
# Build the submit button that we'll pass to the modal. # Build the submit button that we'll pass to the modal.
modal_button = '<button type="submit" ' 'class="usa-button" ' ">Submit request</button>" modal_button = '<button type="submit" ' 'class="usa-button" ' ">Submit request</button>"
# Concatenate the modal header that we'll pass to the modal. # Concatenate the modal header that we'll pass to the modal.
if self.application.requested_domain: if self.application.requested_domain and not self.application.requested_domain.is_incomplete:
modal_heading = "You are about to submit a domain request for " + str(self.application.requested_domain) modal_heading = "You are about to submit a domain request for " + str(self.application.requested_domain)
else: else:
modal_heading = "You are about to submit an incomplete request" modal_heading = "You are about to submit an incomplete request"
@ -549,7 +549,7 @@ class DotgovDomain(ApplicationWizard):
context["organization_type"] = self.application.organization_type context["organization_type"] = self.application.organization_type
context["federal_type"] = self.application.federal_type context["federal_type"] = self.application.federal_type
return context return context
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
"""Override for the post method to mark the DraftDomain as complete""" """Override for the post method to mark the DraftDomain as complete"""
# Set the DraftDomain to "complete" # Set the DraftDomain to "complete"

View file

@ -1,7 +1,6 @@
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):