mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-14 21:44:08 +02:00
Hotfix
This commit is contained in:
parent
f623d00fc2
commit
816d1fe599
2 changed files with 10 additions and 17 deletions
|
@ -1,6 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.db.models import Q
|
|
||||||
from django.http import Http404, HttpResponse, HttpResponseRedirect
|
from django.http import Http404, HttpResponse, HttpResponseRedirect
|
||||||
from django.shortcuts import redirect, render
|
from django.shortcuts import redirect, render
|
||||||
from django.urls import resolve, reverse
|
from django.urls import resolve, reverse
|
||||||
|
@ -11,8 +10,6 @@ from django.contrib import messages
|
||||||
|
|
||||||
from registrar.forms import application_wizard as forms
|
from registrar.forms import application_wizard as forms
|
||||||
from registrar.models import DomainApplication
|
from registrar.models import DomainApplication
|
||||||
from registrar.models.draft_domain import DraftDomain
|
|
||||||
from registrar.models.user import User
|
|
||||||
from registrar.utility import StrEnum
|
from registrar.utility import StrEnum
|
||||||
from registrar.views.utility import StepsHelper
|
from registrar.views.utility import StepsHelper
|
||||||
from registrar.views.utility.permission_views import DomainApplicationPermissionDeleteView
|
from registrar.views.utility.permission_views import DomainApplicationPermissionDeleteView
|
||||||
|
@ -143,9 +140,7 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
|
||||||
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)
|
||||||
|
|
||||||
self._application = DomainApplication.objects.create(
|
self._application = DomainApplication.objects.create(creator=self.request.user)
|
||||||
creator=self.request.user
|
|
||||||
)
|
|
||||||
|
|
||||||
self.storage["application_id"] = self._application.id
|
self.storage["application_id"] = self._application.id
|
||||||
return self._application
|
return self._application
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
from django.utils import timezone
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
from registrar.models import DomainApplication, Domain, UserDomainRole
|
from registrar.models import DomainApplication, Domain, UserDomainRole
|
||||||
|
@ -9,9 +8,9 @@ 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:
|
||||||
|
|
||||||
# Get all domain applications the user has access to
|
# Get all domain applications the user has access to
|
||||||
applications, deletable_applications = _get_applications(request)
|
applications, deletable_applications = _get_applications(request)
|
||||||
|
|
||||||
context["domain_applications"] = applications
|
context["domain_applications"] = applications
|
||||||
|
|
||||||
# Get all domains the user has access to
|
# Get all domains the user has access to
|
||||||
|
@ -34,8 +33,9 @@ def index(request):
|
||||||
|
|
||||||
return render(request, "home.html", context)
|
return render(request, "home.html", context)
|
||||||
|
|
||||||
|
|
||||||
def _get_applications(request):
|
def _get_applications(request):
|
||||||
"""Given the current request,
|
"""Given the current request,
|
||||||
get all DomainApplications that are associated with the UserDomainRole object.
|
get all DomainApplications that are associated with the UserDomainRole object.
|
||||||
|
|
||||||
Returns a tuple of all applications, and those that are deletable by the user.
|
Returns a tuple of all applications, and those that are deletable by the user.
|
||||||
|
@ -47,22 +47,20 @@ def _get_applications(request):
|
||||||
|
|
||||||
# Create a placeholder DraftDomain for each incomplete draft
|
# Create a placeholder DraftDomain for each incomplete draft
|
||||||
valid_statuses = [DomainApplication.ApplicationStatus.STARTED, DomainApplication.ApplicationStatus.WITHDRAWN]
|
valid_statuses = [DomainApplication.ApplicationStatus.STARTED, DomainApplication.ApplicationStatus.WITHDRAWN]
|
||||||
deletable_applications = applications.filter(status__in=valid_statuses, requested_domain=None)
|
deletable_applications = applications.filter(status__in=valid_statuses)
|
||||||
for application in applications:
|
for application in applications:
|
||||||
if application in deletable_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")
|
created_at = application.created_at.strftime("%b. %d, %Y, %I:%M %p UTC")
|
||||||
_name = f"New domain request ({created_at})"
|
_name = f"New domain request ({created_at})"
|
||||||
default_draft_domain = DraftDomain(
|
default_draft_domain = DraftDomain(name=_name, is_complete=False)
|
||||||
name=_name,
|
|
||||||
is_complete=False
|
|
||||||
)
|
|
||||||
|
|
||||||
application.requested_domain = default_draft_domain
|
application.requested_domain = default_draft_domain
|
||||||
|
|
||||||
return (applications, deletable_applications)
|
return (applications, deletable_applications)
|
||||||
|
|
||||||
|
|
||||||
def _get_domains(request):
|
def _get_domains(request):
|
||||||
"""Given the current request,
|
"""Given the current request,
|
||||||
get all domains that are associated with the UserDomainRole object"""
|
get all domains that are associated with the UserDomainRole object"""
|
||||||
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