Merge branch 'za/1676-require-investigator-da' into za/1676-alternative-approach

This commit is contained in:
zandercymatics 2024-02-26 13:03:44 -07:00
commit d11c80e263
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -840,6 +840,10 @@ class DomainApplicationAdminForm(forms.ModelForm):
status = cleaned_data.get("status")
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 = [
DomainApplication.ApplicationStatus.APPROVED,
DomainApplication.ApplicationStatus.IN_REVIEW,
@ -847,11 +851,13 @@ class DomainApplicationAdminForm(forms.ModelForm):
DomainApplication.ApplicationStatus.REJECTED,
DomainApplication.ApplicationStatus.INELIGIBLE
]
# Checks the "investigators" field for validity.
# That field must obey certain conditions when an application is approved.
# Will call "add_error" if any issues are found.
#if status in checked_statuses:
#self._check_for_valid_investigator(investigator)
# If a status change occured, check for validity
if status != initial_status and status in checked_statuses:
# Checks the "investigators" field for validity.
# 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
@ -866,6 +872,7 @@ class DomainApplicationAdminForm(forms.ModelForm):
# Check if an investigator is assigned. No approval is possible without one.
error_message = None
if investigator is None:
# Lets grab the error message from a common location
error_message = ApplicationStatusError.get_error_message(FSMErrorCodes.NO_INVESTIGATOR)
elif not investigator.is_staff:
error_message = ApplicationStatusError.get_error_message(FSMErrorCodes.INVESTIGATOR_NOT_STAFF)