Skip to content

Commit

Permalink
fix(dev): better conditioning;
Browse files Browse the repository at this point in the history
- Check toolkit action instead of plugin name.
  • Loading branch information
JVickery-TBS committed Nov 27, 2023
1 parent 028e42b commit 77d762e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ckanext/xloader/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def notify(self, entity, operation):
# extension will call resource_patch and this method should
# be called again. However, url_changed will not be in the entity
# once Validation does the patch.
if 'validation' in toolkit.config.get('ckan.plugins', []) and \
if _is_validation_plugin_loaded() and \
toolkit.asbool(toolkit.config.get('ckanext.xloader.requires_validation')):
if entity.__dict__.get('extras', {}).get('validation_status', None) != 'success':
log.debug("Skipping xloading resource %s because "
Expand All @@ -139,7 +139,7 @@ def notify(self, entity, operation):
# IResourceController

def after_resource_create(self, context, resource_dict):
if 'validation' in toolkit.config.get('ckan.plugins', []) and \
if _is_validation_plugin_loaded() and \
toolkit.asbool(toolkit.config.get('ckanext.xloader.requires_validation')) and \
resource_dict.get('validation_status', None) != 'success':
log.debug("Skipping xloading resource %s because "
Expand Down Expand Up @@ -246,3 +246,11 @@ def get_helpers(self):
"xloader_status": xloader_helpers.xloader_status,
"xloader_status_description": xloader_helpers.xloader_status_description,
}


def _is_validation_plugin_loaded():
try:
toolkit.get_action('resource_validation_show')
except KeyError:
return False
return True

0 comments on commit 77d762e

Please sign in to comment.