opendatateam / udata

Customizable and skinnable social platform dedicated to open data.
http://udata.readthedocs.org
GNU Affero General Public License v3.0
238 stars 87 forks source link

Add extras fields in Dataset #2590

Open alboutet opened 3 years ago

alboutet commented 3 years ago

Context

We want to add new fields in the Dataset model and let the user modify these values ​​through a form. Extras fields seems to be the way to do it. Can the user have control over these extras fields ?

We have added the field extras in the dataset form. This appears correctly (The default description is present). What is the JSON format to use to add extra fields via this form ? Is it possible to separate the multiple extras fields in the form ?

Thank you

Your Environment

Ubuntu 20.10 Python 3.8.6

pip freeze :

amqp==2.6.1 aniso8601==8.1.1 appdirs==1.4.4 arrow==0.17.0 atomicwrites==1.4.0 attrs==20.3.0 Authlib==0.14.3 awesome-slugify==1.6.5 Babel==2.8.0 bcrypt==3.1.7 billiard==3.6.3.0 binaryornot==0.4.4 bleach==3.1.0 blinker==1.4 bson==0.5.10 celery==4.3.0 celerybeat-mongo==0.2.0 certifi==2020.12.5 cffi==1.14.4 chardet==3.0.4 Click==7.0 colorama==0.4.4 cookiecutter==1.7.2 coverage==4.5.4 cryptography==2.8 Cython==0.29.21 dnspython==2.1.0 docutils==0.16 elasticsearch==2.4.1 elasticsearch-dsl==2.2.0 email-validator==1.1.2 entrypoints==0.3 factory-boy==2.12.0 Faker==3.0.0 feedparser==5.2.1 flake8==3.7.8 Flask==1.0.4 Flask-BabelEx==0.9.3 Flask-Caching==1.8.0 Flask-CDN==1.5.3 Flask-Cors==3.0.8 Flask-DebugToolbar==0.10.1 flask-fs==0.6.1 Flask-Gravatar==0.5.0 Flask-Login==0.4.1 Flask-Mail==0.9.1 flask-mongoengine==0.9.5 Flask-Navigation==0.2.0 Flask-Principal==0.4.0 flask-restplus==0.13.0 Flask-Security-Too==3.4.4 Flask-Sitemap==0.3.0 Flask-Themes2==0.1.4 Flask-WTF==0.14.2 geojson==2.5.0 html2text==2019.9.26 httpretty==0.9.7 idna==2.10 importlib-metadata==3.4.0 invoke==1.3.0 isodate==0.6.0 itsdangerous==1.1.0 jeepney==0.6.0 Jinja2==2.10.3 jinja2-time==0.2.0 jsonschema==3.2.0 keyring==22.0.1 kombu==4.4.0 lxml==4.4.2 MarkupSafe==1.1.1 mccabe==0.6.1 mistune==0.8.4 mock==3.0.5 mongoengine==0.18.2 more-itertools==8.7.0 msgpack==0.6.2 netaddr==0.7.19 nose==1.3.7 packaging==20.9 passlib==1.7.4 pi3==0.0.1 Pillow==7.0.0 pkginfo==1.7.0 pluggy==0.13.1 poyo==0.5.0 py==1.10.0 pycodestyle==2.5.0 pycparser==2.20 pydenticon==0.3.1 pyflakes==2.1.1 Pygments==2.7.4 pymongo==3.10.1 pyparsing==2.4.7 pyrsistent==0.17.3 pytest==4.6.3 pytest-cov==2.6.1 pytest-env==0.6.2 pytest-flask==0.15.0 pytest-mock==2.0.0 pytest-sugar==0.9.2 python-dateutil==2.8.1 python-frontmatter==0.5.0 python-slugify==4.0.1 pytz==2019.3 PyYAML==5.4.1 rdflib==5.0.0 rdflib-jsonld==0.5.0 readme-renderer==28.0 redis==3.3.11 regex==2020.11.13 requests==2.24.0 requests-mock==1.7.0 requests-toolbelt==0.9.1 rfc3986==1.4.0 SecretStorage==3.3.1 simplejson==3.17.0 six==1.15.0 speaklater==1.3 StringDist==1.0.9 termcolor==1.1.0 text-unidecode==1.3 tlds==2021020903 tqdm==4.56.2 twine==3.3.0 ujson==1.35 unicodecsv==0.14.1 Unidecode==0.4.21 uritools==3.0.0 urlextract==0.14.0 urllib3==1.25.11 vine==1.3.0 voluptuous==0.11.7 wcwidth==0.2.5 webencodings==0.5.1 Werkzeug==0.14.1 WTForms==2.2.1 WTForms-JSON==0.3.3 xmltodict==0.12.0 zipp==3.4.0 zxcvbn==4.4.28

abulte commented 3 years ago

Hi,

Using extras for this seems like a reasonable way to go.

We do not currently expose extra fields as editable anywhere. There will be some plumbing to be done to allow the admin interface to expose those extras, possibly with an associated type for validation, and serialize them to the API (which already handles extras saving and validation).

If you want to work on a PR for this (as an opt-in feature) I think it could be useful for some instances.