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

Fetch and display commune name #583

Merged
merged 1 commit into from
Jan 13, 2025
Merged

Fetch and display commune name #583

merged 1 commit into from
Jan 13, 2025

Conversation

Morendil
Copy link
Collaborator

@Morendil Morendil commented Dec 5, 2024

Purpose

New users from communes should be able to make sense of what they can do with Régie.

Proposal

When arriving at Régie from ProConnect, make sure things are set up properly:

  • lookup the Commune using the provided SIRET
  • ensure the Organization is created with the commune's name

Fixes #610

@Morendil Morendil changed the title Set up Org and Domain for Communes Fetch and display commune name Jan 3, 2025
@Morendil Morendil force-pushed the org-and-domain branch 4 times, most recently from b940300 to 003b150 Compare January 3, 2025 22:02
@Morendil Morendil marked this pull request as ready for review January 4, 2025 11:45
@Morendil Morendil requested review from sdemagny and mjeammet January 4, 2025 11:45
@Morendil
Copy link
Collaborator Author

Morendil commented Jan 7, 2025

@PanchoutNathan On est pas dans les clous par rapport à la maquette: est-ce que tu aurais le temps (genre dans la semaine) de committer ou suggérer ce qu'il faudrait faire ? Sinon on peut merger et corriger plus tard… Thx 🙏

Capture d’écran 2025-01-07 à 16 08 33

Copy link
Member

@mjeammet mjeammet left a comment

Choose a reason for hiding this comment

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

Nice ! Let's try and wait for Nathan for a few days if per chance he can adjust the design of the button by the end of the week. Otherwise, let's gooo !

@Morendil
Copy link
Collaborator Author

Morendil commented Jan 9, 2025

@mjeammet This failed in CI for an interesting reason - the API is rate-limited and we got a 429 error. I don't know how we managed to exceed 7 calls/sec. with only one E2E test exercising it… Not sure how best to proceed - perhaps implement retry logic, or try a different API, or use static data… it raises the question of how to deal with failure cases for something like this where the request is made at a specific point in the lifetime of an organization, and not retried afterward.

@Morendil Morendil force-pushed the org-and-domain branch 2 times, most recently from 6a48f84 to c9f083e Compare January 13, 2025 10:25
ANCT-specific extraction of organization names for communes, front
end changes to match.
@Morendil
Copy link
Collaborator Author

I have opted to implement retry logic, and merge with no further delay…

@Morendil Morendil merged commit 20cc173 into main Jan 13, 2025
20 checks passed
@Morendil Morendil deleted the org-and-domain branch January 13, 2025 14:01
Comment on lines +644 to +645
ORGANIZATION_PLUGINS = ["plugins.organizations.NameFromSiretOrganizationPlugin"]

Copy link
Collaborator

Choose a reason for hiding this comment

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

This should not be enforced here because this is not generic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

General reply to your comments: thanks for the feedbacks, I've already hit "merge" but can address these in a later PR (might pick #622 which is in some ways a continuation, or a new one altogether depending on urgency).

Specific reply to the above: OK, I understand the concern here is for users and contributors outside of France to be able to start from a vanilla configuration instead of having to figure out what is French-specific (or even French territorial administration specific) stuff that needs swapping out. And I don't think this case has arisen before so it's a good occasion to start documenting that.

On the other hand I'd like to keep these active for local development and documented in the repo for ease of onboarding. Can we put these in, say, env.d/development/france.dist and pick them up in docker-compose.yml with a comment suggesting creating a country-specific set of env vars, as needed for other countries ?

Comment on lines +691 to +693
OIDC_ORGANIZATION_REGISTRATION_ID_FIELD = "siret"

ORGANIZATION_PLUGINS = ["plugins.organizations.NameFromSiretOrganizationPlugin"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, this should not be enforced here, only in specific tests.

<Text $theme="primary">{userName}</Text>
<Box $flex $direction="column" $align="left">
<Text $theme="primary">{userName}</Text>
{userData?.organization?.registration_id_list?.at(0) && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand the condition, why should it be only when there is a registration ID?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That does seem indirect now you mention it, testing for the name that we're going to display would work just as well. (I think I was biased by the testing perspective, the distinguishing feature of the organization that satisfies that test is that it's the only one in our test data that has a SIRET.)

@@ -55,7 +55,7 @@ backend:
OIDC_RP_SCOPES: "openid email siret"
OIDC_REDIRECT_ALLOWED_HOSTS: https://desk-preprod.beta.numerique.gouv.fr
OIDC_AUTH_REQUEST_EXTRA_PARAMS: "{'acr_values': 'eidas1'}"
ORGANIZATION_PLUGINS: "plugins.organizations.NameFromSiretOrganizationPlugin"
ORGANIZATION_PLUGINS: ["plugins.organizations.NameFromSiretOrganizationPlugin"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will break, django-configurations does not expect a list here: https://github.com/jazzband/django-configurations/blob/master/configurations/values.py#L214

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That one is confusing to me, originally I picked up the string value from this file and used it without change in settings.py, but that broke precisely because it was expecting a list of plugin names and not a singular name. (And it seemed reasonable to me that we'd want potentially more than one plugin…) Do we have different semantics between Helm files and settings.py ?

if commune:
return organization["libelle_commune"].title()

return self._extract_name_from_organization_data(organization)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Warning, the indentation has changed here, this might get the wrong "siret".

Copy link
Collaborator Author

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 see how to construct a case where we'd get the wrong result here (i.e. a missing unit test). The indent is by intention: I did mean to return directly with the libelle_commune in the commune case (because I'm pretty sure the key is always present) and fall through to the invocation of the private method otherwise. (So we end up with a bit of asymmetry in the code with some error handling in one case and not in the other.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants