Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bmonjoie
Copy link
Member

@bmonjoie bmonjoie commented Mar 5, 2025

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

  • Did I use eslint and ruff formatters?
  • Is my code clear enough and well documented?
  • Are my typescript files well typed?
  • New translations have been added or updated if new strings have been introduced in the frontend
  • My migrations file are included
  • Are there enough tests?
  • Documentation has been included (for new feature)

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:

fix: empty instance pop up

Refs: IA-3665

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.

@beygorghor beygorghor changed the title Add a Type to OUCRC IA-4004: Add a Type to OUCRC Mar 6, 2025
@beygorghor beygorghor added the postrelease Should be merged just after the release label Mar 6, 2025
Comment on lines 11 to 20
return [
{
value: orgUnitChangeRequestConfigTypeCreation,
label: formatMessage(MESSAGES.creation),
},
{
value: orgUnitChangeRequestConfigTypeEdition,
label: formatMessage(MESSAGES.edition),
},
];
Copy link
Collaborator

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
@bmonjoie bmonjoie force-pushed the feat/IA-4004_apply_oucrc_to_creation branch from 934b1f6 to 413f5c1 Compare March 10, 2025 12:57
Copy link
Member

@tdethier tdethier left a 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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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)
Copy link
Member

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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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):
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
postrelease Should be merged just after the release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants