Skip to content

Commit

Permalink
Merge pull request #78 from qld-gov-au/merge_upstream
Browse files Browse the repository at this point in the history
chore: merge upstream
  • Loading branch information
ThrawnCA authored Dec 16, 2024
2 parents 53abd3c + 5ecf4e1 commit f3ec306
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions ckanext/validation/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ def after_dataset_update(self, context, data_dict):

utils.validate_resource(context, resource)

# IPackageController

# CKAN < 2.10
def before_index(self, index_dict):
if (self._data_dict_is_dataset(index_dict)):
return self.before_dataset_index(index_dict)
Expand Down
2 changes: 0 additions & 2 deletions ckanext/validation/settings.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# encoding: utf-8

import json

import ckantoolkit as tk


import ckan.plugins as plugins

from ckanext.validation.interfaces import IDataValidation
Expand Down
7 changes: 4 additions & 3 deletions ckanext/validation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,12 @@ def _get_new_file_stream(file):


def run_async_validation(resource_id):
context = {u'ignore_auth': True}
data_dict = {u'resource_id': resource_id, u'async': True}

try:
tk.get_action(u'resource_validation_run')(context, data_dict)
tk.get_action(u'resource_validation_run')(
{u'ignore_auth': True},
{u'resource_id': resource_id,
u'async': True})
except tk.ValidationError as e:
log.warning(u'Could not run validation for resource {}: {}'.format(
resource_id, e))
Expand Down
8 changes: 7 additions & 1 deletion ckanext/validation/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ def get_validators():
return {"{}".format(func.__name__): func for func in validators}


# Input validators

def resource_schema_validator(value, context):

if not value:
return

msg = None

if isinstance(value, string_types):
if isinstance(value, dict):
descriptor = value

elif isinstance(value, string_types):
value = str(value)

if value.lower().startswith('http'):
return value
Expand Down

0 comments on commit f3ec306

Please sign in to comment.