-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IA-4004: Add a Type
to OUCRC
#2011
base: main
Are you sure you want to change the base?
Conversation
return [ | ||
{ | ||
value: orgUnitChangeRequestConfigTypeCreation, | ||
label: formatMessage(MESSAGES.creation), | ||
}, | ||
{ | ||
value: orgUnitChangeRequestConfigTypeEdition, | ||
label: formatMessage(MESSAGES.edition), | ||
}, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can useMemo
here
OUCRC now have a type to differentiate them between OrgUnit edition and creation. The UI has been adapted to take this into consideration and the APIs as well. In the mobile endpoint, a new `include_creation` parameter has been added not to break with the existing applications which do not expect two kinds of OUCRC. IA-4004, IA-4005, IA-4006
934b1f6
to
413f5c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only checked the backend since the front was already done.
Overall: good job, as expected 👍
I'm requesting changes only for the serializer suggestion.
Other suggestions/comments in unit tests are nitpicking, but updating these things will make someone's job easier whenever we need to debug something in these tests later.
And also, @kemar's input might be useful for the "fake OUCRC generation" part.
@@ -185,6 +190,7 @@ class BaseOrgUnitChangeRequestConfigurationWriteUpdateSerializer(serializers.Mod | |||
class Meta: | |||
model = OrgUnitChangeRequestConfiguration | |||
fields = [ | |||
"type", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"type", |
I would not include it in the update serializer, in order to avoid changing the type of an existing OUCRC
queryset.exclude(org_unit_type__in=non_editable_org_unit_type_ids), | ||
queryset.exclude( | ||
Q(org_unit_type__in=non_editable_org_unit_type_ids) | ||
& Q(type=OrgUnitChangeRequestConfiguration.Type.EDITION) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand why you need to exclude editions here
# Results should be ordered by ID by default, so the new one will always be last | ||
self.assertEqual(result[0]["id"], self.oucrc_type_water.id) | ||
self.assertEqual(result[1]["id"], new_oucrc.id) | ||
self.assertEqual(result[1]["id"], self.oucrc_type_water_creation.id) | ||
self.assertEqual(result[2]["id"], new_oucrc.id) | ||
|
||
# Filtering on an orgunit type with a single OUCRC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably remove this comment now 😁
@@ -37,7 +38,7 @@ def test_filter_config_on_project_id(self): | |||
response = self.client.get(f"{self.OUCRC_API_URL}?project_id={self.project_johto.id}") | |||
self.assertJSONResponse(response, 200) | |||
result = response.json()["results"] | |||
self.assertEqual(3, len(result)) # The 3 OUCRCs created in setup | |||
self.assertEqual(6, len(result)) # The 6 OUCRCs created in setup | |||
|
|||
# Making sure that the 3 results do not include the new OUCRC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Making sure that the 3 results do not include the new OUCRC | |
# Making sure that the 6 results do not include the new OUCRC |
@@ -799,11 +827,32 @@ def test_check_availability_error_missing_parameter(self): | |||
) | |||
self.assertIn("project_id", response.json()) | |||
|
|||
def test_check_availability_error_missing_parameter_type(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this test 👍
{ | ||
APP_ID: self.app_id, | ||
}, | ||
) | ||
self.assertJSONResponse(response, status.HTTP_200_OK) | ||
self.assertEqual(3, len(response.data["results"])) # the 3 OUCRCs from setup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.assertEqual(3, len(response.data["results"])) # the 3 OUCRCs from setup | |
self.assertEqual(3, len(response.data["results"])) # the 3 edition OUCRCs from setup |
OUCRC now have a type to differentiate them between OrgUnit edition and creation.
Related JIRA tickets : IA-4004, IA-4005, IA-4006
Self proofreading checklist
Changes
The UI has been adapted to take this into consideration and the APIs as well.
In the mobile endpoint, a new
include_creation
parameter has been added not to break with the existing applications which do not expect two kinds of OUCRC.How to test
Go to the OUCRC screen and add configuration for creation. You can filter them, delete them, etc.
Follow the Conventional Commits specification
The merge message of a pull request must follow the Conventional Commits specification.
This convention helps to automatically generate release notes.
Use lowercase for consistency.
Example:
Note that the Jira reference is preceded by a line break.
Both the line break and the Jira reference are entered in the Add an optional extended description… field.