Skip to content

Commit

Permalink
fix(logic): ignore not sysadmin;
Browse files Browse the repository at this point in the history
- Added `ignore_not_sysadmin` validator to the sync key.
JVickery-TBS committed Aug 9, 2024

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
1 parent 378f69f commit 6070740
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions ckanext/xloader/action.py
Original file line number Diff line number Diff line change
@@ -40,10 +40,6 @@ def xloader_submit(context, data_dict):
:param ignore_hash: If set to True, the xloader will reload the file
even if it haven't changed. (optional, default: False)
:type ignore_hash: bool
:param sync: If set to True, the xloader callback will be executed right
away, instead of a job being enqueued. It will also delete any existing jobs
for the given resource. (optional, default: False)
:type sync: bool
Returns ``True`` if the job has been submitted and ``False`` if the job
has not been submitted, i.e. when ckanext-xloader is not configured.
@@ -59,7 +55,11 @@ def xloader_submit(context, data_dict):

p.toolkit.check_access('xloader_submit', context, data_dict)

# If sync is set to True, the xloader callback will be executed right
# away, instead of a job being enqueued. It will also delete any existing jobs
# for the given resource. This is only controlled by sysadmins or the system.
sync = data_dict.pop('sync', False)

res_id = data_dict['resource_id']
try:
resource_dict = p.toolkit.get_action('resource_show')(context, {
3 changes: 2 additions & 1 deletion ckanext/xloader/schema.py
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
boolean_validator = get_validator('boolean_validator')
int_validator = get_validator('int_validator')
OneOf = get_validator('OneOf')
ignore_not_sysadmin = get_validator('ignore_not_sysadmin')

if p.toolkit.check_ckan_version('2.9'):
unicode_safe = get_validator('unicode_safe')
@@ -29,7 +30,7 @@ def xloader_submit_schema():
'id': [ignore_missing],
'set_url_type': [ignore_missing, boolean_validator],
'ignore_hash': [ignore_missing, boolean_validator],
'sync': [ignore_missing, boolean_validator],
'sync': [ignore_missing, boolean_validator, ignore_not_sysadmin],
'__junk': [empty],
'__before': [dsschema.rename('id', 'resource_id')]
}

0 comments on commit 6070740

Please sign in to comment.