From 4832d9eeedf406c81ea76d37f41ff704e01e80ed Mon Sep 17 00:00:00 2001 From: Neda Taherifar Date: Thu, 6 Jun 2024 11:54:39 +0800 Subject: [PATCH] Modify the code to add the full URL for DOI in related_resources. --- .../ckanext/igsn_theme/logic/action.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ckan/src/ckanext-igsn-theme/ckanext/igsn_theme/logic/action.py b/ckan/src/ckanext-igsn-theme/ckanext/igsn_theme/logic/action.py index 41f0c0c9..52058a00 100644 --- a/ckan/src/ckanext-igsn-theme/ckanext/igsn_theme/logic/action.py +++ b/ckan/src/ckanext-igsn-theme/ckanext/igsn_theme/logic/action.py @@ -33,8 +33,8 @@ def organization_list_for_user(next_action, context, data_dict): @tk.chained_action def package_create(next_action, context, data_dict): - # logger = logging.getLogger(__name__) - # logger.info("data_dict: %s", pformat(data_dict)) + logger = logging.getLogger(__name__) + logger.info("package_create data_dict: %s", pformat(data_dict)) package_type = data_dict.get('type') package_plugin = lib_plugins.lookup_package_plugin(package_type) @@ -87,10 +87,15 @@ def generate_parent_related_resource(data_dict): new_index = highest_index + 1 data_dict[f'related_resource-{new_index}-related_resource_type'] = "PhysicalObject" - data_dict[f'related_resource-{new_index}-related_resource_url'] = parent.get('doi') data_dict[f'related_resource-{new_index}-related_resource_title'] = parent.get('title') data_dict[f'related_resource-{new_index}-relation_type'] = "IsDerivedFrom" + doi_value = parent.get('doi') + if doi_value: + if 'https' not in doi_value: + doi_value = "https://doi.org/" + doi_value + data_dict[f'related_resource-{new_index}-related_resource_url'] = doi_value + # We do not need user_create customization here. # Users do not need to be a part of an organization by default. @tk.chained_action