Skip to content

Commit

Permalink
Merge pull request #1395 from open-data/fix/can-validate-implementation
Browse files Browse the repository at this point in the history
IDataValidation implementation for Registry
  • Loading branch information
JVickery-TBS authored Jul 26, 2023
2 parents 2a81ba6 + 931137c commit 86bffdc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ckanext/canada/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ class DataGCCAInternal(p.SingletonPlugin):
p.implements(p.IPackageController, inherit=True)
p.implements(p.IActions)
p.implements(p.IResourceUrlChange)
try:
from ckanext.validation.interfaces import IDataValidation
except ImportError:
log.warn('failed to import ckanext-validation interface')
else:
p.implements(IDataValidation, inherit=True)

def update_config(self, config):
p.toolkit.add_template_directory(config, 'templates/internal')
Expand Down Expand Up @@ -232,6 +238,16 @@ def get_actions(self):
resource_view_create=resource_view_create_bilingual,
)

# IDataValidation

def can_validate(self, context, resource):
"""
Only uploaded resources are allowed to be validated
"""
if resource.get(u'url_type') != u'upload':
return False
return True



@chained_action
Expand Down

0 comments on commit 86bffdc

Please sign in to comment.