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

Unifier les créations de comptes pour les mairies et les comptes Saas #4871

Merged
merged 21 commits into from
Dec 11, 2024

Conversation

victormours
Copy link
Contributor

@victormours victormours commented Dec 5, 2024

Avant

Formulaire pour les mairies Formulaire pour les comptes Saas
Screenshot 2024-12-05 at 14 46 09 Screenshot 2024-12-05 at 14 45 45

Après

Un formulaire unique, avec une checkbox à activer pour les mairies
Screenshot 2024-12-05 at 14 45 00

Contexte

Cette PR est une première amélioration pour un point de douleur remonté par l'équipe déploiement pendant le séminaire : le fait que toutes les mairies soient dans le même territoire complique les choses.

C'est notamment impossible de permettre à une mairie qui utilise RDV SP de créer une organisation pour son CCAS en autonomie.

Ça limite aussi beaucoup les usages avancés du produit via l'espace admin, parce que les mairies n'ont pas accès à l'espace admin.

Ça complique le suivi de dossier pour l'équipe déploiement, parce qu'il n'y a pas le fonctionnement 1 territoire = 1 compte.

Solution

Cette PR est une première étape pour unifier les créations de comptes Saas et Mairies, et de faire que la connexion à l'ants soit une option supplémentaire, et pas un fonctionnement complètement différent.

On ajoute la colonne organisations.ants_connectable, et on pourra ensuite sortir individuellement des mairies du territoire commun avec le script fait pour cet usage (scripts/split_territory.rb).

@victormours victormours marked this pull request as draft December 5, 2024 10:44
@victormours victormours marked this pull request as ready for review December 5, 2024 13:47
Copy link
Contributor

@francois-ferrandis francois-ferrandis left a comment

Choose a reason for hiding this comment

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

Encore un quick win qui vaut son pesant d'or ! 🚀

.where(organisations: { territory_id: Territory.mairies&.id })
.where(organisations: { ants_connectable: true })
Copy link
Contributor

Choose a reason for hiding this comment

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

C'est beau ! 🤩

Comment on lines +9 to +14
up_only do
mairies_territory = Territory.find_by(name: "Mairies")
if mairies_territory # La migration tourne aussi sur l'instance historique qui n'a pas ce territoire
Organisation.where(territory_id: mairies_territory.id).update_all(ants_connectable: true)
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Si mon cerveau est encore en vie, il me semble qu'on aura aucune interruption puisque la migration s'exécute dans une transaction, et que le l'ancien code est compatible avec le nouveau schéma. 🚀

Comment on lines 77 to 96
expect(page).to have_link("modifier", href: prendre_rdv_path(departement: "MA", public_link_organisation_id: organisation.id, duration: 50))
expect(page).to have_link("modifier",
href: prendre_rdv_path(departement: "MA", motif_name_with_location_type: passport_motif.name_with_location_type, public_link_organisation_id: organisation.id,
duration: 50))
expect(page).to have_link("modifier",
href: prendre_rdv_path(departement: "MA", lieu_id: lieu.id, motif_name_with_location_type: passport_motif.name_with_location_type,
public_link_organisation_id: organisation.id, duration: 50))

expect(page).to have_link("modifier", href: prendre_rdv_path(
departement: organisation.territory.departement_number,
public_link_organisation_id: organisation.id,
duration: 50
))

expect(page).to have_link("modifier", href: prendre_rdv_path(
departement: organisation.territory.departement_number,
motif_name_with_location_type: passport_motif.name_with_location_type,
public_link_organisation_id: organisation.id,
duration: 50
))

expect(page).to have_link("modifier", href: prendre_rdv_path(
departement: organisation.territory.departement_number,
lieu_id: lieu.id,
motif_name_with_location_type: passport_motif.name_with_location_type,
public_link_organisation_id: organisation.id, duration: 50
))
Copy link
Contributor

Choose a reason for hiding this comment

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

Oui s'il vous plaît merci beaucoup 🤩

if compte.save
if compte.save!
Copy link
Contributor

Choose a reason for hiding this comment

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

Un peu étrange de voir un if et une méthode bang, c'est contraire à la convention Rails de ne pas retourner de valeur pour les méthodes bang, mais plutôt de raise des exceptions.

Le choix de ce ! est-il motivé par la capacité de la méthode à lever des exceptions ?

Bref, c'est du chipotage, mais j'ai dû aller regarder l'implem de la méthode pour confirmer que c'était pas une erreur d'usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oui, cette méthode peut lever des exceptions, j'ai ajouté ça pour le rendre plus clair, mais j'ai eu la flemme de changer l'implém du controller pour mieux gérer ça

@victormours victormours marked this pull request as draft December 9, 2024 14:02
@victormours
Copy link
Contributor Author

vu avec Matis et Léa : il faut vérifier comment les catégories de motifs s'afficheront pour les organisations qui n'ont pas vocation à se brancher à l'ants, et ça pose peut-être la question plus large de comment on clarifie ce branchement pour les agents.

@victormours victormours force-pushed the mairies-with-full-territories branch from 4e5a578 to 05e9c92 Compare December 11, 2024 14:22
@victormours victormours marked this pull request as ready for review December 11, 2024 14:49
@victormours
Copy link
Contributor Author

victormours commented Dec 11, 2024

Okay, ça marche dans le cas où on commence par créer une mairie, et ensuite un ouvre un CCAS.
Ça ne marche pas encore sans intervention des devs si on a un CCAS et ensuite on ouvre une mairie.
C'est validé avec Léa

fill_in(:compte_agent_last_name, with: "Factice") # Plusieurs champs ont le label "Nom", donc on utilise le name de l'input
fill_in("Adresse mail", with: "francis@factice.org")
select("Urbanisme", from: "Service")
fill_in_form
Copy link
Contributor

Choose a reason for hiding this comment

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

chipotage : je pense qu’il aurait mieux valu dupliquer les appels plutôt que génériser, et éventuellement changer les valeurs pour la cohérence par ex fill_in("Nom de la première organisation", with: "Mairie de Romainville")

departement: organisation.territory.departement_number,
lieu_id: lieu.id,
motif_name_with_location_type: passport_motif.name_with_location_type,
public_link_organisation_id: organisation.id, duration: 50
Copy link
Contributor

Choose a reason for hiding this comment

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

chipotage ultime : le duration ne revient pas à la ligne

gros 👍 pour le réalignement en tout cas

@@ -52,7 +52,7 @@ def search_application_ids

def self.lieux
Lieu.joins(:organisation)
.where(organisations: { territory_id: Territory.mairies&.id })
.where(organisations: { ants_connectable: true })
Copy link
Contributor

Choose a reason for hiding this comment

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

très cool en effet 🙇

En revanche, ça n’est pas 100% sûr avec la migration non ?
Si l’ANTS nous requête sur cet endpoint entre le moment où on déploie et le moment où la migration est achevée, on ne va pas renvoyer les bons lieux il me semble.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

si, vu qu'on ajoute la colonne avant que le nouveau code soit actif

@victormours victormours force-pushed the mairies-with-full-territories branch from 9d5166a to 42402ae Compare December 11, 2024 17:04
@victormours victormours force-pushed the mairies-with-full-territories branch from 42402ae to 8468759 Compare December 11, 2024 17:05
@victormours victormours enabled auto-merge (squash) December 11, 2024 17:06
@victormours victormours merged commit 30bcc13 into production Dec 11, 2024
15 checks passed
@victormours victormours deleted the mairies-with-full-territories branch December 11, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants