Commit dbc66020 authored by Willem ter Berg's avatar Willem ter Berg

proper dataset loading for system-property validation

parent d99ab448
......@@ -20,7 +20,7 @@ def create_schema(schema):
is_resource_id = tk.get_validator('resource_id_exists')
referentiedata_on_create = tk.get_validator('referentiedata_on_create')
high_value_on_create = tk.get_validator('high_value_on_create')
basisregister_on_create = tk.get_validator('basisregister_on_update')
basisregister_on_create = tk.get_validator('basisregister_on_create')
link_status_default = tk.get_validator('link_status_default')
schema.update({
......
......@@ -4,6 +4,7 @@
Provides validation methods that enforce system properties management.
"""
from ckan.plugins.toolkit import get_action
import ckan.authz as authz
......@@ -38,8 +39,8 @@ def referentiedata_on_update(key, data_dict, errors, context):
if isinstance(data_dict[key], bool) and authz.is_sysadmin(context.get('user')):
return key, data_dict, errors, context
stored_dataset = context['session'].query(context['model'].Package).get(data_dict[('id',)])
data_dict[key] = stored_dataset[('extras', 'referentiedata',)]
current_dataset = get_action('package_show')(context, {'id': data_dict[('id',)]})
data_dict[key] = current_dataset[('referentiedata',)]
return key, data_dict, errors, context
......@@ -75,8 +76,8 @@ def high_value_on_update(key, data_dict, errors, context):
if isinstance(data_dict[key], bool) and authz.is_sysadmin(context.get('user')):
return key, data_dict, errors, context
stored_dataset = context['session'].query(context['model'].Package).get(data_dict[('id',)])
data_dict[key] = stored_dataset[('extras', 'high_value',)]
current_dataset = get_action('package_show')(context, {'id': data_dict[('id',)]})
data_dict[key] = current_dataset[('high_value',)]
return key, data_dict, errors, context
......@@ -112,8 +113,8 @@ def basisregister_on_update(key, data_dict, errors, context):
if isinstance(data_dict[key], bool) and authz.is_sysadmin(context.get('user')):
return key, data_dict, errors, context
stored_dataset = context['session'].query(context['model'].Package).get(data_dict[('id',)])
data_dict[key] = stored_dataset[('extras', 'high_value',)]
current_dataset = get_action('package_show')(context, {'id': data_dict[('id',)]})
data_dict[key] = current_dataset[('basisregister',)]
return key, data_dict, errors, context
......@@ -146,7 +147,7 @@ def link_status_update(key, data_dict, errors, context):
if isinstance(data_dict[key], bool) and authz.is_sysadmin(context.get('user')):
return key, data_dict, errors, context
stored_dataset = context['session'].query(context['model'].Resource).get(data_dict[('id',)])
data_dict[key] = stored_dataset[('link_status',)]
current_dataset = get_action('resource_show')(context, {'id': data_dict[('id',)]})
data_dict[key] = current_dataset[('link_status',)]
return key, data_dict, errors, context
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment