mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 20:18:38 +02:00
Cleanup
This commit is contained in:
parent
d416ea5138
commit
79d3c1821d
2 changed files with 12 additions and 14 deletions
|
@ -824,6 +824,10 @@ class DomainApplicationAdminForm(forms.ModelForm):
|
||||||
status = cleaned_data.get("status")
|
status = cleaned_data.get("status")
|
||||||
investigator = cleaned_data.get("investigator")
|
investigator = cleaned_data.get("investigator")
|
||||||
|
|
||||||
|
# Get the old status
|
||||||
|
initial_status = self.initial.get("status", None)
|
||||||
|
|
||||||
|
# We only care about investigator when in these statuses
|
||||||
checked_statuses = [
|
checked_statuses = [
|
||||||
DomainApplication.ApplicationStatus.APPROVED,
|
DomainApplication.ApplicationStatus.APPROVED,
|
||||||
DomainApplication.ApplicationStatus.IN_REVIEW,
|
DomainApplication.ApplicationStatus.IN_REVIEW,
|
||||||
|
@ -831,11 +835,13 @@ class DomainApplicationAdminForm(forms.ModelForm):
|
||||||
DomainApplication.ApplicationStatus.REJECTED,
|
DomainApplication.ApplicationStatus.REJECTED,
|
||||||
DomainApplication.ApplicationStatus.INELIGIBLE
|
DomainApplication.ApplicationStatus.INELIGIBLE
|
||||||
]
|
]
|
||||||
# Checks the "investigators" field for validity.
|
|
||||||
# That field must obey certain conditions when an application is approved.
|
# If a status change occured, check for validity
|
||||||
# Will call "add_error" if any issues are found.
|
if status != initial_status and status in checked_statuses:
|
||||||
#if status in checked_statuses:
|
# Checks the "investigators" field for validity.
|
||||||
#self._check_for_valid_investigator(investigator)
|
# That field must obey certain conditions when an application is approved.
|
||||||
|
# Will call "add_error" if any issues are found.
|
||||||
|
self._check_for_valid_investigator(investigator)
|
||||||
|
|
||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
|
||||||
|
@ -850,6 +856,7 @@ class DomainApplicationAdminForm(forms.ModelForm):
|
||||||
# Check if an investigator is assigned. No approval is possible without one.
|
# Check if an investigator is assigned. No approval is possible without one.
|
||||||
error_message = None
|
error_message = None
|
||||||
if investigator is None:
|
if investigator is None:
|
||||||
|
# Lets grab the error message from a common location
|
||||||
error_message = ApplicationStatusError.get_error_message(FSMErrorCodes.NO_INVESTIGATOR)
|
error_message = ApplicationStatusError.get_error_message(FSMErrorCodes.NO_INVESTIGATOR)
|
||||||
elif not investigator.is_staff:
|
elif not investigator.is_staff:
|
||||||
error_message = ApplicationStatusError.get_error_message(FSMErrorCodes.INVESTIGATOR_NOT_STAFF)
|
error_message = ApplicationStatusError.get_error_message(FSMErrorCodes.INVESTIGATOR_NOT_STAFF)
|
||||||
|
|
|
@ -739,15 +739,6 @@ class DomainApplication(TimeStampedModel):
|
||||||
if Domain.objects.filter(name=self.requested_domain.name).exists():
|
if Domain.objects.filter(name=self.requested_domain.name).exists():
|
||||||
raise ApplicationStatusError(code=FSMErrorCodes.APPROVE_DOMAIN_IN_USE)
|
raise ApplicationStatusError(code=FSMErrorCodes.APPROVE_DOMAIN_IN_USE)
|
||||||
|
|
||||||
# Check if an investigator is assigned. No approval is possible without one.
|
|
||||||
if self.investigator is None:
|
|
||||||
raise ApplicationStatusError(code=FSMErrorCodes.APPROVE_NO_INVESTIGATOR)
|
|
||||||
|
|
||||||
# Investigators must be staff users.
|
|
||||||
# This is handled elsewhere, but we should check here as a precaution.
|
|
||||||
if not self.investigator.is_staff:
|
|
||||||
raise ApplicationStatusError(code=FSMErrorCodes.APPROVE_INVESTIGATOR_NOT_STAFF)
|
|
||||||
|
|
||||||
# == Create the domain and related components == #
|
# == Create the domain and related components == #
|
||||||
created_domain = Domain.objects.create(name=self.requested_domain.name)
|
created_domain = Domain.objects.create(name=self.requested_domain.name)
|
||||||
self.approved_domain = created_domain
|
self.approved_domain = created_domain
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue