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

fix(permission) add the json params to the checked params #2712

Merged
merged 2 commits into from
Sep 28, 2023

Conversation

Pierre-Narcisi
Copy link
Contributor

@Pierre-Narcisi Pierre-Narcisi commented Sep 19, 2023

Fix le problème de permissions dans Occtax, Occhab et Import sur la liste des JDD (les permissions C du module n'étaient pas prise en compte, mais seulement celles du R sur Métadonnées)

@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

All modified lines are covered by tests ✅

Files Coverage Δ
backend/geonature/core/gn_meta/models.py 93.45% <100.00%> (+1.16%) ⬆️
backend/geonature/core/gn_meta/routes.py 77.72% <100.00%> (+0.57%) ⬆️

... and 8 files with indirect coverage changes

📢 Thoughts on this report? Let us know!.

Copy link
Contributor

@bouttier bouttier left a comment

Choose a reason for hiding this comment

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

Il y a eu avoir des changements dans le composant dataset car historiquement les infos était passé par query string et non par POST (si je me souviens bien – et ça expliquerai cette regression).
Globalement, il vaut mieux qu’une route mélange les paramètres query string et les paramètres POST. En effet, les données par POST sont typées contrairement aux données par query string, ce qui peut amener à pas mal de confusion (comme interpréter comme vrai la chaîne de texte false).
En revanche il ne pose pas de soucis d’avoir certains paramètres par query string, et d’autres par POST, mais il faut faire attention à bien les transmettre de la manière attendu.

@@ -103,6 +103,8 @@ def get_datasets():
:returns: `list<TDatasets>`
"""
params = MultiDict(request.args)
if request.is_json:
params.update(MultiDict(request.json))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
params.update(MultiDict(request.json))
params.update(request.json)

update accepte un mapping donc un dict

@Pierre-Narcisi Pierre-Narcisi force-pushed the fix/datasets-route branch 6 times, most recently from f692130 to 8a8f1b8 Compare September 27, 2023 14:51
query = TDatasets.query.filter_by_creatable(params.pop("create"))
create = params.pop("create").split(".")
if len(create) > 1:
query = TDatasets.query.filter_by_creatable(create[0], object_code=create[1])
Copy link
Member

@TheoLechemia TheoLechemia Sep 28, 2023

Choose a reason for hiding this comment

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

Peut être nommé les paramètres ?

Suggested change
query = TDatasets.query.filter_by_creatable(create[0], object_code=create[1])
query = TDatasets.query.filter_by_creatable(module_code=create[0], object_code=create[1])

Je rajouterais bien aussi dans la docstring le fait qu'on peut passer le module_code + le object_code dans "create". ça fait une mini doc sur l'API pour qu'on s'en souvienne

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pas faux, on risque d'oublier pourquoi ya ca sinon

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

Successfully merging this pull request may close these issues.

4 participants