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

Touristicevent organizers in many to many #3587 #3864

Conversation

TheoLechemia
Copy link
Contributor

Description

Transform the field organizer to a many to many field name organizers
The PR keep retrocompatibilty on the API : the attribute organizer now return a concatened string of the organizers labels. We still can filter on organisms with the organism parameter
However the field organizer_id is now named organizers_id and return a list of id organism

Related Issue

#3587

Checklist

  • I have followed the guidelines in our Contributing document
  • My code respects the Definition of done available in the Development section of the documentation
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes
  • I added an entry in the changelog file
  • My commits are all using prefix convention (emoji + tag name) and references associated issues
  • I added a label to the PR corresponding to the perimeter of my contribution
  • The title of my PR mentionned the issue associated

Copy link

cypress bot commented Dec 20, 2023

Passing run #8105 ↗︎

0 24 0 0 Flakiness 0

Details:

Merge 201f9f7 into ad649e5...
Project: Geotrek-admin Commit: 0dffdb1c24 ℹ️
Status: Passed Duration: 02:10 💡
Started: Feb 28, 2024 2:24 PM Ended: Feb 28, 2024 2:26 PM

Review all test suite changes for PR #3864 ↗︎

@TheoLechemia TheoLechemia force-pushed the impr_touristic_event_organizers branch 3 times, most recently from 1d98523 to cbf2bf3 Compare December 20, 2023 17:07
organizer_id = serializers.PrimaryKeyRelatedField(
read_only=True
)
organizer = serializers.SerializerMethodField(source="organizers")
Copy link
Member

Choose a reason for hiding this comment

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

Si organizer est une liste, nomme le au pluriel

Suggested change
organizer = serializers.SerializerMethodField(source="organizers")
organizers = serializers.SerializerMethodField()

Par contre, quid de la retrocompat ?
l'aggregateur utilise l'api v2, i lfaut qu'on puisse importer les données avec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Merci pour les retours.
J'avais garder le "organizer" au singulier justement pour la rétrocompatibilité. Mais vu que le champs en maintenant en M2M, de toute façon il va falloir revoir pleins de choses.
Je me proposais de revoir aussi la partie parser, pour assurer la retrocompat

Copy link
Member

Choose a reason for hiding this comment

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

Oui, on utilise aussi la propriété "organizer" dans Geotrek-rando-v3, c'est pour ça qu'on ne l'avait pas renommé.
Mais de mémoire, on peut faire un synonyme pour gérer la transition et que "organizers" ou "organizer" fonctionne ?

read_only=True
)
organizer = serializers.SerializerMethodField(source="organizers")
organizer_id = serializers.SerializerMethodField(source="organizers")
Copy link
Member

Choose a reason for hiding this comment

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

idem pour le nom (source="organizers" n'est pas necessaire pour un serializers.SerializerMethodField)

return ", ".join(
map(lambda org: org.label, organizers)
)
return None
Copy link
Member

@submarcos submarcos Dec 22, 2023

Choose a reason for hiding this comment

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

en temps normal j'aurai suggéré d'utiliser .values_list(), mais pour que le prefetch fonctionne il vaut mieux 👍🏼

       def get_organizer(self, obj):
               return ", ".join(
                        map(lambda org: org.label, obj.organizers.all())
                    )

attention à if obj.organizers:, c'est un manager de M2M pas une liste, c'est tjrs == True

return None

def get_organizer_id(self, obj):
return [org.id for org in obj.organizers.get_queryset()]
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
return [org.id for org in obj.organizers.get_queryset()]
return [org.id for org in obj.organizers.all()]

msgstr ""

#: geotrek/tourism/tests/test_functional.py:131
#: geotrek/tourism/tests/test_functional.py:277
Copy link
Member

Choose a reason for hiding this comment

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

pour les trads, il faut mettre à jour tous les fichiers de toutes les langues, (sans -l en) et en utilisant l'indication pour ne pas rajoter tous ces commentaires (--no-location)
https://github.com/GeotrekCE/Geotrek-admin/blob/master/Makefile#L41

return ", ".join(
map(lambda org: org.label, organizers)
)
return None
Copy link
Member

Choose a reason for hiding this comment

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

meme remarques que dans les serializers API v2 pour le nom / contenu

@babastienne babastienne changed the title 💫 Improvements - touristicevent organizers in many to many #3587 Touristicevent organizers in many to many #3587 Dec 26, 2023
@TheoLechemia TheoLechemia force-pushed the impr_touristic_event_organizers branch 3 times, most recently from dec5b6d to d2b3b69 Compare January 24, 2024 16:08
@TheoLechemia TheoLechemia force-pushed the impr_touristic_event_organizers branch from c0a7ab3 to 5e2ff46 Compare February 23, 2024 09:12
Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.35%. Comparing base (c46c2e5) to head (201f9f7).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3864   +/-   ##
=======================================
  Coverage   98.35%   98.35%           
=======================================
  Files         294      294           
  Lines       22285    22309   +24     
=======================================
+ Hits        21918    21942   +24     
  Misses        367      367           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheoLechemia TheoLechemia force-pushed the impr_touristic_event_organizers branch from 5e2ff46 to 39a2b9f Compare February 23, 2024 10:01
@TheoLechemia
Copy link
Contributor Author

J'ai corrigé les derniers tests sur les parsers

@TheoLechemia
Copy link
Contributor Author

Tout est bon sur cette PR, sauf les fichiers de langues.
Quand je lance
docker compose run --rm web ./manage.py makemessages -a --no-location --no-obsolete
j'ai un
PermissionError: [Errno 13] Permission denied: './docs/_build/html/CONTRIBUTING.html.py'
je suis preneur si vous avez des idées

Copy link
Member

@submarcos submarcos left a comment

Choose a reason for hiding this comment

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

I think there is a problem with your traslation files.
https://github.com/GeotrekCE/Geotrek-admin/pull/3864/files#diff-fc6029e51be9d381ebe39b2b526f0a10f7cb10fd0ed1800e0a79048e8dbe58d3 is too big.

I supose you create a local venv folder that is parsed by makemessages

@TheoLechemia
Copy link
Contributor Author

Yes I had a venv. I re run make messages after deleting it

@submarcos
Copy link
Member

Yes I had a venv. I re run make messages after deleting it

Your changes in geotrek/locales shoud be reverted

@TheoLechemia TheoLechemia force-pushed the impr_touristic_event_organizers branch from f88bc2b to 201f9f7 Compare February 28, 2024 14:12
@submarcos submarcos linked an issue Feb 28, 2024 that may be closed by this pull request
@submarcos
Copy link
Member

replaced by #3965

@submarcos submarcos closed this Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants