From c6c7974ec6a94e4acd5369b24bf5190ac0aa3f9f Mon Sep 17 00:00:00 2001 From: Jesper Zedlitz <jesper@zedlitz.de> Date: Mon, 15 Aug 2022 09:22:30 +0200 Subject: [PATCH] check owner_org against configuration option Check if the validate is performed during harvesting and the owner_org of the dataset is contained in the new `ckanext.odsh.lenient_with` config option. --- ckanext/odsh/validation.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ckanext/odsh/validation.py b/ckanext/odsh/validation.py index 4b9b7ce2..cb900c99 100644 --- a/ckanext/odsh/validation.py +++ b/ckanext/odsh/validation.py @@ -64,12 +64,13 @@ def validate_extra_groups(data, requireAtLeastOne, errors): def validate_extras(key, data, errors, context): extra_errors = {} - isStaNord = ('id',) in data and data[('id',)][:7] == 'StaNord' - isLVermGeo = ('owner_org',) in data and data[('owner_org',)] == '01115337-01d1-4e96-aa8e-9749524889c7' - isUmweltportal = ('owner_org',) in data and data[('owner_org',)] == '09871195-cd0a-4767-9396-276404c940d9' + harvesting = ('ignore_auth' in context) and (context['ignore_auth'] == True) + owner_org = data[('owner_org',)] + lenient_with = config.get('ckanext.odsh.lenient_with','') + is_optional_temporal_start = toolkit.asbool( config.get('ckanext.odsh.is_optional_temporal_start', False) - ) or isStaNord or isLVermGeo or isUmweltportal + ) ( harvesting and (owner_org in lenient_with) ) require_at_least_one_category = toolkit.asbool( config.get('ckanext.odsh.require_at_least_one_category', False) -- GitLab