Skip to content

Commit

Permalink
Added print for debuging
Browse files Browse the repository at this point in the history
  • Loading branch information
blagojabozinovski committed Mar 26, 2024
1 parent 0eb829a commit dff418f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
14 changes: 11 additions & 3 deletions ckanext/validation/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ def resource_validation_run(context, data_dict):
:rtype: string
'''
print("===========validation check access===========")

t.check_access(u'resource_validation_run', context, data_dict)


if not data_dict.get(u'resource_id'):
raise t.ValidationError({u'resource_id': u'Missing value'})

Expand All @@ -92,7 +94,9 @@ def resource_validation_run(context, data_dict):

# TODO: limit to sysadmins
async_job = data_dict.get(u'async', True)

print("=================print async_job=========")
print(async_job)
print("=================print async_job=========")
# Ensure format is supported
if not resource.get(u'format', u'').lower() in settings.SUPPORTED_FORMATS:
raise t.ValidationError(
Expand All @@ -108,13 +112,15 @@ def resource_validation_run(context, data_dict):
# Check if there was an existing validation for the resource

Session = context['model'].Session

print('========================sesion==============')
try:
validation = Session.query(Validation).filter(
Validation.resource_id == data_dict['resource_id']).one()
except NoResultFound:
validation = None

print('========================validation==============')
print(validation)
print('========================validation==============')
if validation:
# Reset values
validation.finished = None
Expand All @@ -129,8 +135,10 @@ def resource_validation_run(context, data_dict):
Session.commit()

if async_job:
print('========================vo async job sum==============')
enqueue_job(run_validation_job, [resource])
else:
print('========================async job e false==============')
run_validation_job(resource)


Expand Down
29 changes: 19 additions & 10 deletions ckanext/validation/plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ def _process_schema_fields(self, data_dict):

return data_dict

def before_create(self, context, data_dict):

def before_resource_create(self, context, data_dict):
print("=================vo before create si===========")
is_dataset = self._data_dict_is_dataset(data_dict)
if not is_dataset:
context["_resource_create_call"] = True
return self._process_schema_fields(data_dict)

def after_create(self, context, data_dict):

def after_resource_create(self, context, data_dict):
print("=================vo after create si===========")
is_dataset = self._data_dict_is_dataset(data_dict)

if not get_create_mode_from_config() == u'async':
Expand Down Expand Up @@ -206,8 +206,8 @@ def _handle_validation_for_resource(self, context, resource):

_run_async_validation(resource[u'id'])

def before_update(self, context, current_resource, updated_resource):

def before_resource_update(self, context, current_resource, updated_resource):
print("=================vo before update si===========")
updated_resource = self._process_schema_fields(updated_resource)

# the call originates from a resource API, so don't validate the entire package
Expand Down Expand Up @@ -246,10 +246,12 @@ def before_update(self, context, current_resource, updated_resource):

return updated_resource

def after_update(self, context, data_dict):

def after_resource_update(self, context, data_dict):
print("=================vo after update si vo __init__.py===========")
is_dataset = self._data_dict_is_dataset(data_dict)

print('=================is dataset=========')
print(is_dataset)
print('=================is dataset=========')
# Need to allow create as well because resource_create calls
# package_update
if (not get_update_mode_from_config() == u'async'
Expand Down Expand Up @@ -290,17 +292,24 @@ def after_update(self, context, data_dict):
self._handle_validation_for_resource(context, resource)

else:
print('=================this is a resource=========')
# This is a resource
resource_id = data_dict[u'id']
print('============resource id==========')
print(resource_id)
print('============resource id==========')

print('============od ovde e problemot==========')

breakpoint()
if resource_id in self.resources_to_validate:
for plugin in p.PluginImplementations(IDataValidation):
if not plugin.can_validate(context, data_dict):
log.debug('Skipping validation for resource %s', data_dict['id'])
return

del self.resources_to_validate[resource_id]

print('============do ovde e problemot==========')
_run_async_validation(resource_id)

# IPackageController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</div>
</div>

{# Schema Upload #}
<!-- {# Schema Upload #}
{{ form.input(
'schema_upload',
label='Upload Data Schema',
Expand All @@ -28,7 +28,7 @@
error='',
classes=['control-full']
)
}}
}} -->

{# Schema URL #}
{{ form.input(
Expand Down

0 comments on commit dff418f

Please sign in to comment.