Skip to content

Commit

Permalink
[MDS-5973] Project Summary backend validation error on older existing…
Browse files Browse the repository at this point in the history
… projects (#3095)

* wrapping all ams backend validation behind ams_agent feature flag

* removing repeated code
  • Loading branch information
asinn134 authored May 13, 2024
1 parent ded80ef commit 407ab48
Showing 1 changed file with 61 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -728,12 +728,6 @@ def validate_project_summary(cls, data):
'surface_level_data': [],
'basic_info': [],
'project_contacts': [],
'authorizations': [],
'applicant_info': [],
'agent': [],
'facility': [],
'legal_land': [],
'declaration': [],
}

# Validate surface level data of payload
Expand All @@ -746,65 +740,74 @@ def validate_project_summary(cls, data):
if basic_info_validation != True:
errors_found['basic_info'].append(basic_info_validation)

# Validate Authorizations Involved
if (status_code == 'SUB'
and is_feature_enabled(Feature.AMS_AGENT)
and len(ams_authorizations.get('amendments', [])) == 0
and len(ams_authorizations.get('new', [])) == 0
and len(authorizations) == 0):
errors_found['authorizations'].append('Authorizations Involved not provided')

for authorization in authorizations:
authorization_validation = ProjectSummaryAuthorization.validate_authorization(authorization, False)
if authorization_validation != True:
errors_found['authorizations'].append(authorization_validation)

if ams_authorizations:
for authorization in ams_authorizations.get('amendments', []):
ams_authorization_amendments_validation = ProjectSummaryAuthorization.validate_authorization(authorization, True)
if ams_authorization_amendments_validation != True:
errors_found['authorizations'].append(ams_authorization_amendments_validation)

for authorization in ams_authorizations.get('new', []):
ams_authorization_new_validation = ProjectSummaryAuthorization.validate_authorization(authorization, True)
if ams_authorization_new_validation != True:
errors_found['authorizations'].append(ams_authorization_new_validation)

# Validate Project Contacts
for contact in contacts:
contact_validation = Project.validate_project_contacts(contact)
if contact_validation != True:
errors_found['project_contacts'].append(contact_validation)

# Validate Applicant Information
if applicant != None:
applicant_validation = ProjectSummary.validate_project_party(applicant, 'applicant')
if applicant_validation != True:
errors_found['applicant_info'].append(applicant_validation)

# Validate Agent
if is_agent == True:
agent_validation = ProjectSummary.validate_project_party(agent, 'agent')
if agent_validation != True:
errors_found['agent'].append(agent_validation)
if is_feature_enabled(Feature.AMS_AGENT):
errors_found |= {
'authorizations': [],
'applicant_info': [],
'agent': [],
'facility': [],
'legal_land': [],
'declaration': [],
}

# Validate Authorizations Involved
if (status_code == 'SUB'
and len(ams_authorizations.get('amendments', [])) == 0
and len(ams_authorizations.get('new', [])) == 0
and len(authorizations) == 0):
errors_found['authorizations'].append('Authorizations Involved not provided')

for authorization in authorizations:
authorization_validation = ProjectSummaryAuthorization.validate_authorization(authorization, False)
if authorization_validation != True:
errors_found['authorizations'].append(authorization_validation)

if ams_authorizations:
for authorization in ams_authorizations.get('amendments', []):
ams_authorization_amendments_validation = ProjectSummaryAuthorization.validate_authorization(authorization, True)
if ams_authorization_amendments_validation != True:
errors_found['authorizations'].append(ams_authorization_amendments_validation)

for authorization in ams_authorizations.get('new', []):
ams_authorization_new_validation = ProjectSummaryAuthorization.validate_authorization(authorization, True)
if ams_authorization_new_validation != True:
errors_found['authorizations'].append(ams_authorization_new_validation)

# Validate Applicant Information
if applicant != None:
applicant_validation = ProjectSummary.validate_project_party(applicant, 'applicant')
if applicant_validation != True:
errors_found['applicant_info'].append(applicant_validation)

# Validate Agent
if is_agent == True:
agent_validation = ProjectSummary.validate_project_party(agent, 'agent')
if agent_validation != True:
errors_found['agent'].append(agent_validation)

# Validate Facility Operator Information
if facility_operator != None:
facility_validation = ProjectSummary.validate_project_party(facility_operator, 'facility_operator')
if facility_validation != True:
errors_found['facility'].append(facility_validation)

# Validate Legal Land Owner Information
if is_legal_land_owner == False:
legal_land_validation = ProjectSummary.validate_legal_land(data)
if legal_land_validation != True:
errors_found['legal_land'].append(legal_land_validation)

# Validate Declaration
if status_code == 'SUB' and is_feature_enabled(Feature.AMS_AGENT):
declaration_validation = ProjectSummary.validate_declaration(data)
if declaration_validation != True:
errors_found['declaration'].append(declaration_validation)
# Validate Facility Operator Information
if facility_operator != None:
facility_validation = ProjectSummary.validate_project_party(facility_operator, 'facility_operator')
if facility_validation != True:
errors_found['facility'].append(facility_validation)

# Validate Legal Land Owner Information
if is_legal_land_owner == False:
legal_land_validation = ProjectSummary.validate_legal_land(data)
if legal_land_validation != True:
errors_found['legal_land'].append(legal_land_validation)

# Validate Declaration
if status_code == 'SUB':
declaration_validation = ProjectSummary.validate_declaration(data)
if declaration_validation != True:
errors_found['declaration'].append(declaration_validation)

return errors_found

Expand Down

0 comments on commit 407ab48

Please sign in to comment.