From 039ac7c0ad81277c63b09ce99123e584e4ae3d4a Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 14 Aug 2014 15:31:39 +0100 Subject: [PATCH] Always remove harvest extras on after_show if there Up until now we where relying on `for_edit` being present in the context, but this is only added on the controllers. It's better to be safe and remove them always. If needed (at index time) they will be added afterwards. --- ckanext/harvest/plugin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ckanext/harvest/plugin.py b/ckanext/harvest/plugin.py index d2e7432..0ddc573 100644 --- a/ckanext/harvest/plugin.py +++ b/ckanext/harvest/plugin.py @@ -97,10 +97,10 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm): .filter(HarvestObject.current==True) \ .first() - if context.get('for_edit') and 'extras' in data_dict: - # If we are editing the dataset, check if the harvest extras - # are there, and if so, remove them. This can happen eg when - # doing resource_update, which calls package_show + # If the harvest extras are there, remove them. This can happen eg + # when calling package_update or resource_update, which call + # package_show + if data_dict.get('extras'): data_dict['extras'][:] = [e for e in data_dict.get('extras', []) if not e['key'] in ('harvest_object_id', 'harvest_source_id', 'harvest_source_title',)]