Skip to content

Commit 0147bde

Browse files
committed
fixup! feat(eap): update revise workflow with locked feature
1 parent 6023ad1 commit 0147bde

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

eap/serializers.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,13 @@ def _validate_status(self, validated_data: dict[str, typing.Any]) -> dict[str, t
10051005

10061006
# Check latest EAP has NS Addressing Comments file uploaded
10071007
if self.instance.get_eap_type_enum == EAPType.SIMPLIFIED_EAP:
1008+
# NOTE: If EAP is locked, NS has to revise the EAP to address the comments before resubmitting.
1009+
if self.instance.latest_simplified_eap.is_locked:
1010+
raise serializers.ValidationError(
1011+
gettext("Cannot change status to %s, Please revise the EAP to address the comments.")
1012+
% EAPRegistration.Status(new_status).label
1013+
)
1014+
10081015
if not (self.instance.latest_simplified_eap and self.instance.latest_simplified_eap.updated_checklist_file):
10091016
raise serializers.ValidationError(
10101017
{
@@ -1034,6 +1041,12 @@ def _validate_status(self, validated_data: dict[str, typing.Any]) -> dict[str, t
10341041
)
10351042

10361043
else:
1044+
if self.instance.latest_full_eap.is_locked:
1045+
raise serializers.ValidationError(
1046+
gettext("Cannot change status to %s, Please revise the EAP to address the comments.")
1047+
% EAPRegistration.Status(new_status).label
1048+
)
1049+
10371050
if not (self.instance.latest_full_eap and self.instance.latest_full_eap.updated_checklist_file):
10381051
raise serializers.ValidationError(
10391052
{

eap/test_views.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,13 @@ def test_status_transition(self):
13241324
self.eap_registration.latest_simplified_eap.review_checklist_file,
13251325
)
13261326

1327+
# Fails, As NS has to revise the EAP before transitioning to UNDER_REVIEW.
1328+
status_data = {
1329+
"status": EAPStatus.UNDER_REVIEW,
1330+
}
1331+
response = self.client.post(self.url, status_data)
1332+
self.assertEqual(response.status_code, 400, response.data)
1333+
13271334
# Fails, As User only can revise after NS_ADDRESSING_COMMENTS, cannot update directly as it's locked
13281335
update_data["modified_at"] = datetime.now()
13291336
response = self.client.patch(url, update_data, format="json")
@@ -1452,6 +1459,13 @@ def test_status_transition(self):
14521459
self.assertEqual(response.status_code, 200, response.data)
14531460
self.assertEqual(response.data["status"], EAPStatus.NS_ADDRESSING_COMMENTS)
14541461

1462+
# Fails, As NS has to revise the EAP before transitioning to UNDER_REVIEW.
1463+
status_data = {
1464+
"status": EAPStatus.UNDER_REVIEW,
1465+
}
1466+
response = self.client.post(self.url, status_data)
1467+
self.assertEqual(response.status_code, 400, response.data)
1468+
14551469
# Cannot update as it is in NS_ADDRESSING_COMMENTS, only revise is allowed
14561470
update_data["modified_at"] = datetime.now()
14571471
response = self.client.patch(url, update_data, format="json")
@@ -1587,6 +1601,13 @@ def test_status_transition(self):
15871601
self.assertEqual(response.status_code, 200, response.data)
15881602
self.assertEqual(response.data["status"], EAPStatus.NS_ADDRESSING_COMMENTS)
15891603

1604+
# Fails, As NS has to revise the EAP before transitioning to UNDER_REVIEW.
1605+
status_data = {
1606+
"status": EAPStatus.UNDER_REVIEW,
1607+
}
1608+
response = self.client.post(self.url, status_data)
1609+
self.assertEqual(response.status_code, 400, response.data)
1610+
15901611
revise_url = f"/api/v2/simplified-eap/{third_snapshot.id}/revise/"
15911612
self.authenticate(self.country_admin)
15921613
response = self.client.post(revise_url)
@@ -1737,7 +1758,7 @@ def test_status_transition(self):
17371758
# FAILS As simplified EAP is in PENDING_PFA, cannot updated
17381759
url = f"/api/v2/simplified-eap/{simplified_eap.id}/"
17391760
response = self.client.patch(url, update_data, format="json")
1740-
self.assertEqual(response.status_code, 400)
1761+
self.assertEqual(response.status_code, 400, response.data)
17411762

17421763
# NOTE: Transition to APPROVED
17431764
# PENDING_PFA -> APPROVED
@@ -1767,7 +1788,7 @@ def test_status_transition(self):
17671788
self.authenticate(self.country_admin)
17681789
url = f"/api/v2/simplified-eap/{simplified_eap.id}/"
17691790
response = self.client.patch(url, update_data, format="json")
1770-
self.assertEqual(response.status_code, 400)
1791+
self.assertEqual(response.status_code, 400, response.data)
17711792

17721793
@mock.patch("eap.serializers.generate_export_eap_pdf")
17731794
@mock.patch("eap.serializers.group")

0 commit comments

Comments
 (0)