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

Add schema based model metadata field #3

Open
thclark opened this issue May 14, 2021 · 0 comments
Open

Add schema based model metadata field #3

thclark opened this issue May 14, 2021 · 0 comments
Labels
backend Related to the back end feature A new feature of the app

Comments

@thclark
Copy link
Contributor

thclark commented May 14, 2021

Feature request

Use Case

In the SynchroinisedDatastores, we need to store metadata as well as file blobs. It would be good if we could just use a schema, consistent with the upcoming tags template work in twined and Octue SDK, to generate a metadata JSONField that's still queryable but for which the form is automatically created.

django-reactive is pretty good because it allows us to use a json schema to create data in django admin which then can be used to store metadata; maybe base something on this?


from django_reactive.fields import ReactJSONSchemaField

class MyModel(models.Model)
    tags = ReactJSONSchemaField(
        help_text="Tags enable data to be found using common search tools.",
        schema={
            "type": "object",
            "required": [
                "elevation",
                "max_latitude",
                "max_longitude",
                "min_latitude",
                "min_longitude",
            ],
            "properties": {
                "elevation": {
                    "type": "number",
                    "title": "Elevation",
                    "description": "Height in m above the ground that the wind map is calculated"
                },
                "max_latitude": {
                    "type": "number",
                    "title": "Max Latitude"
                },
                "max_longitude": {
                    "type": "number",
                    "title": "Max Longitude"
                },
                "min_latitude": {
                    "type": "number",
                    "title": "Min Longitude"
                },
                "min_longitude": {
                    "type": "number",
                    "title": "Min Longitude"
                },
            },
            "additionalProperties": True
        }
    )

Current state

Currently we use the META_FIELDS property to map database columns to metadata but it would be nice to be able to reflect out metadata directly instead of having to manually map it for each file type

@thclark thclark added backend Related to the back end feature A new feature of the app labels May 14, 2021
@thclark thclark removed this from Octue Board Dec 1, 2021
@thclark thclark moved this to Priority 1 (Low) in Octue Board Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to the back end feature A new feature of the app
Projects
Status: Priority 1 (Low)
Development

No branches or pull requests

1 participant