openig / geotrek_admin_aggregator

Apache License 2.0
2 stars 1 forks source link

2 - implicit/explicit declaration of fields in mapping #9

Open IdrissaD opened 2 years ago

IdrissaD commented 2 years ago

Fields that have the exact same name in the API results and in Geotrek models are explicitely declared for now, in env.py:

"attachments" : {
        "author" : "author",
        "title" : "title",
        "legend" : "legend",
        "uuid" : "uuid",
    },

Implicit mapping would imply that if an API field has the same name than a model field, thus the API field value should be assigned to the model field. It could ease the code maintenance and automatically adapt to the creation of new fields in further Geotrek-admin/API v2 versions.

This functioning should be explained in code comments.

IdrissaD commented 2 years ago

Selected solution: explicit mapping with a last elif condition allowing implicit mapping.