ckanext-scheming icon indicating copy to clipboard operation
ckanext-scheming copied to clipboard

Feature request: retain extra fields

Open florianm opened this issue 10 years ago • 7 comments

Not sure whether this is a bug or a feature, but it seems that enabling ckanext-scheming with a custom schema will, on first saving a dataset with the new schema, delete any existing "extra" fields. Even to only retain the existing extra fields to safely migrate data would be helpful - this could be achieved if config settings would toggle the display of existing extra fields and/or form fields.

florianm avatar Dec 16 '14 08:12 florianm

Just not yet implemented.

The way I'm using scheming I don't want free-form extras, but many users would like to still offer support and the combining schema extras and free-form extras should work with the latest ckan master. We should have a way to specify if free-form dataset extras should be allowed with a schema.

wardi avatar Dec 18 '14 20:12 wardi

Cool, no worries. I've got some prod data in extra fields which is tricky to migrate as any edit to a dataset with scheming fields deletes any extra fields. Would be great to choose from displaying extra fields or not, and retaining them (or not). Had a look in the code but couldn't figure out where the magic needs to happen :-)

florianm avatar Dec 19 '14 10:12 florianm

@wardi as scheming disables free-form extra fields, and harvesting requires them, what's the path of least resistance to ckan_harvest between two ckan instances with (easy: the same, harder: different) custom dataset schemas?

florianm avatar Aug 20 '15 03:08 florianm

@florianm free-form extras should work if we just add the edit fields back to the template. Care to give that a try?

The only problem is: how do we handle free-form extras with names that match the ones in the schema?

wardi avatar Aug 23 '15 18:08 wardi

Just in case someone wants this (and I think lots do), here's a copy-pastable solution:

In ckanext-scheming/ckanext/scheming/templates/scheming/package/snippets/package_form.html

from

{% block metadata_fields %}
{% endblock %}

to

{% block metadata_fields %}
  {% block package_metadata_fields_custom %}
    {% block custom_fields %}
      {% snippet 'snippets/custom_form_fields.html', extras=data.extras, errors=errors, limit=3 %}
    {% endblock %}
  {% endblock %}
{% endblock %}

CarlQLange avatar Jan 25 '16 16:01 CarlQLange

@CarlQLange Thanks a lot, this works just fine (y)

NicolaiLolansen avatar Feb 01 '17 14:02 NicolaiLolansen

@wardi There is already logic which checks if a key is defined in the root or under extras.

GordianDziwis avatar Jun 14 '23 18:06 GordianDziwis