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

Allow override of dataset badges #3189

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

maudetes
Copy link
Contributor

@maudetes maudetes commented Nov 8, 2024

Fix datagouv/data.gouv.fr#1564

This is a quickfix for the dataset case, we may want to find a cleaner solution that apply to all.

@maudetes
Copy link
Contributor Author

maudetes commented Nov 8, 2024

This fix has been deployed in production to fix saving SPD datasets.
Could we discuss this next week @magopian? :)

@magopian
Copy link
Contributor

Sure thing @maudetes!

Copy link
Contributor

@magopian magopian left a comment

Choose a reason for hiding this comment

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

Thank you very much for this, indeed, it's a bit frightening to see we can break udata-front with what felt like basic changes on the backend 😱

Nice code, nice test, excellent work 💯

class DatasetBadge(Badge):
kind = db.StringField(required=True, choices=list(BADGES.keys()))
kind = db.StringField(required=True, validation=validate_badge)
Copy link
Contributor

Choose a reason for hiding this comment

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

using choices makes it use a dropdown in swagger, which is convenient, but I don't know any existing way to have a dynamic list of choices... so I guess we have to let go of that convenience ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've actually tried keeping choices with a lambda to compute the value dynamically but I could not make it work sadely

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, I tried also in the past, and couldn't make it work. There doesn't seem to be a way to do it, other than hacking/monkeypatching the lib itself, which seemed a little bit too much at the time.

I'll have a deeper look in the future if it's prioritized 👍

@maudetes
Copy link
Contributor Author

If we keep this direction, we may want to apply the same logic to other badges type

magopian added a commit that referenced this pull request Nov 14, 2024
Follows up on #3189, fixes
[#1564](datagouv/data.gouv.fr#1564)

---------

Co-authored-by: maudetes <[email protected]>
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.

Soucis de validation de badge des datasets
3 participants