-
Notifications
You must be signed in to change notification settings - Fork 37
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
(PC-29882)[BO] feat: Logging of location modification during venue up… #12919
Conversation
0ecd149
to
03679c9
Compare
api/src/pcapi/core/offerers/api.py
Outdated
address = get_or_create_address(location_data) | ||
location_data_ = { |
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.
Je trouve que le nom porte à confusion. Est-ce que l'on pourrait prendre quelque chose comme snapshot_location_data
?
@@ -756,6 +756,20 @@ def format_modified_info_name(info_name: str) -> str: | |||
return "Date d'éligibilité à la nouvelle interface Pro" | |||
case "confidenceRule.confidenceLevel": | |||
return "Validation des offres" | |||
case "Offereraddress.addressid": | |||
return "Table Addresse <> ID Adresse" |
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.
Est-ce que les noms ont été vus avec PO ?
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.
Non j'ai proposé ça mais je reboucle avec lui.
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.
Je te laisse revoir, mais une chose est sûre : un seul « d » dans Adresse en français 🙂
@@ -756,6 +756,20 @@ def format_modified_info_name(info_name: str) -> str: | |||
return "Date d'éligibilité à la nouvelle interface Pro" | |||
case "confidenceRule.confidenceLevel": | |||
return "Validation des offres" | |||
case "Offereraddress.addressid": |
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.
Est-ce pertinent d'avoir l'ID ici ? Je ne vois pas d'autres IDs définies ailleurs dans ce case.
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.
oui c'est un peu particulier par ce qu'on a ce comportement que sur OA. C'est pour marquer l'association de l'OA à une autre adresse. Est ce qu'on l'omet ?
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.
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.
J'en profite aussi pour ressusciter ça : je suis pas hyper convaincu non plus d'afficher le changement d'id, je sais pas si ça va vraiment servir à l'utilisateur...
@@ -1105,6 +1165,7 @@ def test_update_venue_without_double_model_writing(self, authenticated_client, o | |||
assert mails_testing.outbox[0]["template"] == TransactionalEmail.VENUE_NEEDS_PICTURE.value.__dict__ | |||
assert mails_testing.outbox[0]["params"]["VENUE_NAME"] == venue.common_name | |||
assert mails_testing.outbox[0]["params"]["VENUE_FORM_URL"] == urls.build_pc_pro_venue_link(venue) | |||
# assert not double action_history data |
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.
oubli ?
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.
Peux-tu rebase sur master s'il te plaît, pour clarifier les différences après résolution des conflits ?
0d0b773
to
a74c7ff
Compare
api/src/pcapi/core/offerers/api.py
Outdated
if not venue.isVirtual and FeatureToggle.ENABLE_ADDRESS_WRITING_WHILE_CREATING_UPDATING_VENUE.is_active(): | ||
venue_snapshot = update_venue_location(venue, modifications, author=author, is_manual_edition=is_manual_edition) | ||
else: | ||
venue_snapshot = history_api.ObjectUpdateSnapshot(venue, author) |
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.
Je pense qu'il serait préférable de garder la création de l'objet snapshot toujours au même endroit et de la passer en paramètre, plutôt que le créer soit ici soit dans l'autre fonction en fonction de la situation.
if not venue.isVirtual and FeatureToggle.ENABLE_ADDRESS_WRITING_WHILE_CREATING_UPDATING_VENUE.is_active(): | |
venue_snapshot = update_venue_location(venue, modifications, author=author, is_manual_edition=is_manual_edition) | |
else: | |
venue_snapshot = history_api.ObjectUpdateSnapshot(venue, author) | |
venue_snapshot = history_api.ObjectUpdateSnapshot(venue, author) | |
if not venue.isVirtual and FeatureToggle.ENABLE_ADDRESS_WRITING_WHILE_CREATING_UPDATING_VENUE.is_active(): | |
update_venue_location(venue, modifications, author=author, venue_snapshot, is_manual_edition=is_manual_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.
Mais du coup la fonction update location ne peut pas realiser les update (en db) vu que l'update doit etre fait juste avant le .add_action pour garder qu'une ligne dans l'historique. On aura alors une fonction update_location qui update rien. ça peut prêter a confusion.
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.
Je ne comprends pas le problème, puisque ma suggestion est de toujours créer l'objet ici, donc avant l'appel à la fonction plutôt qu'exactement la même ligne au tout début de la fonction appelée. Quelle différence dans le résultat ?
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.
On arrive à la même chose. j'avoue que je m'attend à une homogénéité des signature sur les fonctions qui sont logiquement semblable. Mais c'est un autre sujet
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.
ok je te laisse choisir ce qui te semble la meilleure solution en fonction aussi des autres utilisations de cette fonction.
@@ -756,6 +756,20 @@ def format_modified_info_name(info_name: str) -> str: | |||
return "Date d'éligibilité à la nouvelle interface Pro" | |||
case "confidenceRule.confidenceLevel": | |||
return "Validation des offres" | |||
case "Offereraddress.addressid": |
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.
@@ -756,6 +756,20 @@ def format_modified_info_name(info_name: str) -> str: | |||
return "Date d'éligibilité à la nouvelle interface Pro" | |||
case "confidenceRule.confidenceLevel": | |||
return "Validation des offres" | |||
case "Offereraddress.addressid": | |||
return "Table Addresse <> ID Adresse" |
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.
Je te laisse revoir, mais une chose est sûre : un seul « d » dans Adresse en français 🙂
assert update_snapshot["latitude"]["new_info"] == "48.87171" | ||
assert update_snapshot["longitude"]["new_info"] == "2.308289" # rounding due to Decimal column in db | ||
assert update_snapshot["venueTypeCode"]["new_info"] == data["venue_type_code"] | ||
assert update_snapshot["offererAddress.address.latitude"]["new_info"] == "48.87171" |
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.
Peux-tu ajouter vérifier dans un test qu'on n'a pas de modification sur latitude et longitude lorsqu'elle n'a pas changé ? Car en édition manuelle j'obtiens.
Peut-être l'un des tests en-dessous se prête-t-il à la vérification.
Indice pour corriger le bug : https://github.com/pass-culture/pass-culture-main/blob/v296.0.1/api/src/pcapi/core/history/api.py#L94
@@ -748,6 +748,20 @@ def format_modified_info_name(info_name: str) -> str: | |||
return "Date d'éligibilité à la nouvelle interface Pro" | |||
case "confidenceRule.confidenceLevel": | |||
return "Validation des offres" | |||
case "Offereraddress.addressid": | |||
return "Table Addresse <> ID Adresse" | |||
case "offereraddress.address.city": |
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.
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.
Je ne vois que l'inseecode qui manque.
Est ce que le wording: ex "Table Address <> Longitude" te va ?
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.
J'aurais probablement simplement écrit « Adresse - Longitude » mais ça reste mineur et se corrige.
Certes inseeCode manque, mais addressid et address.city ne sont pas bien affichés.
8d86f3d
to
94840c4
Compare
case "offererAddress.addressId": | ||
return "Adresse - ID Adresse" | ||
case "offererAddress.address.inseeCode": | ||
return "Address - Code Insee" |
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.
return "Address - Code Insee" | |
return "Adresse - Code Insee" |
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.
Tu n'as pas modifié...
api/src/pcapi/core/offerers/api.py
Outdated
@@ -248,13 +260,39 @@ def update_venue_location(venue: models.Venue, modifications: dict, is_manual_ed | |||
) | |||
|
|||
address = get_or_create_address(location_data, is_manual_edition=is_manual_edition) | |||
|
|||
snaphot_location_data = { |
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.
snaphot_location_data = { | |
snapshot_location_data = { |
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.
Et pourquoi pas snapshot_address_data
d'ailleurs ?
api/src/pcapi/core/offerers/api.py
Outdated
if venue.offererAddress | ||
else geography_models.Address() |
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.
Je comprends pas ce if else. On teste juste au-dessus l'existence de venue.offererAddressId
...
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.
c'est surtout pour contenter mypy.
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.
Dans ce cas, soit tu peux faire un if venue.offererAddress
plus haut, soit tu peux utiliser un assert
juste avant, avec une mention que c'est pour mypy (cf les nombreux # helps mypy
que tu peux trouver)
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.
J'insiste un peu pour ces ifs, ça ne rend vraiment pas le code clair
api/src/pcapi/core/offerers/api.py
Outdated
target = venue.offererAddress if venue.offererAddress else models.OffererAddress() | ||
venue_snapshot.trace_update( | ||
{"addressId": address.id}, target=target, field_name_template="offererAddress.{}" | ||
) |
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.
C'est un doublon ? Ou alors je comprends pas ce qu'on fait...
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.
en fait il y a OffererAddress.AddressId et OffererAddress.address.id. Il faudrait avoir un id dans le snapshot. mais la on aurait doublon.
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.
Ah... Mais ça donnera du coup un doublon dans l'historique non ? Enfin, sur le BO, on aura les deux lignes de modif ?
@@ -695,6 +689,7 @@ def update_venue(venue_id: int) -> utils.BackofficeResponse: | |||
contact_data=contact_data, | |||
criteria=criteria, | |||
external_accessibility_url=form.acceslibre_url.data if hasattr(form, "acceslibre_url") else "", | |||
is_manual_edition=((not venue.isVirtual) and form.is_manual_address.data == "on"), |
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.
On ne garde pas le if du FF ?
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.
il est dans le update_venue. et l'argument est utilisé que la bas.
94840c4
to
789e7f5
Compare
api/src/pcapi/core/offerers/api.py
Outdated
if venue.offererAddress | ||
else geography_models.Address() |
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.
J'insiste un peu pour ces ifs, ça ne rend vraiment pas le code clair
api/src/pcapi/core/offerers/api.py
Outdated
venue_snapshot.trace_update( | ||
snapshot_location_data, target=target, field_name_template="offererAddress.address.{}" | ||
) | ||
target = venue.offererAddress if venue.offererAddress else models.OffererAddress() |
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.
Et pareil pour ce if
case "offererAddress.addressId": | ||
return "Adresse - ID Adresse" | ||
case "offererAddress.address.inseeCode": | ||
return "Address - Code Insee" |
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.
Tu n'as pas modifié...
789e7f5
to
19cd424
Compare
19cd424
to
c1541ae
Compare
c1541ae
to
82d0b2c
Compare
logger dans action_history les modification de localisation lors de la modification d'un lieu
But de la pull request
Ticket Jira (ou description si BSR) : https://passculture.atlassian.net/browse/PC-29882
Vérifications