From 06e6e6bac2c1d78f55c7ffa2c43df69a601d4282 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Mon, 16 Oct 2023 09:23:01 +0200 Subject: [PATCH 1/3] Updated EPERSONGROUP_DICT from `ersongroup_dict.json` to `epersongroup_dict.json` --- migration_const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration_const.py b/migration_const.py index 94b87b6..ef4f01c 100644 --- a/migration_const.py +++ b/migration_const.py @@ -12,7 +12,7 @@ # mapping dict names EPERSON_DICT = "eperson_dict.json" USER_REGISTRATION_DICT = "user_registration_dict.json" -EPERSONGROUP_DICT = "ersongroup_dict.json" +EPERSONGROUP_DICT = "epersongroup_dict.json" COMMUNITY_DICT = "community_dict.json" COLLECTION_DICT = "collection_dict.json" ITEM_DICT = "item_dict.json" From 4ba96176fdfbf63cca3aa8dfe4afa2ac2bafa618 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Mon, 16 Oct 2023 09:23:31 +0200 Subject: [PATCH 2/3] Updated .gitingore to ingore `.data/ .temp-files/` folders --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1a800d2..8aa10d2 100644 --- a/.gitignore +++ b/.gitignore @@ -137,5 +137,5 @@ debug.log.txt clarin-dspace-dump-8.8.23 # data folders -.data/ -.temp-files/ +data/ +temp-files/ From e452b39e41a84a600b9f80468a0d866175314ccf Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Mon, 16 Oct 2023 09:23:56 +0200 Subject: [PATCH 3/3] Updated importing licenses to replace definition url and updated README.md --- README.md | 3 +++ const.py | 6 ++++++ data_pump/license.py | 20 +++++++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 92caa42..4f4eb3c 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,9 @@ Update `const.py` - `CLARIN_DSPACE_7_PORT = 5432` - `CLARIN_DSPACE_7_USER = ""` - `CLARIN_DSPACE_7_PASSWORD = ""` +#### const - for importing licenses +- `OLD_LICENSE_DEFINITION_STRING = ` +- `NEW_LICENSE_DEFINITION_STRING = ` **NOTE:** Be sure, that `authorization = True`, because some of the used endpoints won't work diff --git a/const.py b/const.py index bb454ba..aee9f78 100644 --- a/const.py +++ b/const.py @@ -64,6 +64,12 @@ CLARIN_DSPACE_7_USER = "" CLARIN_DSPACE_7_PASSWORD = "" +# IMPORTING LICENSES +# String which should be replaced +OLD_LICENSE_DEFINITION_STRING = 'https://lindat.mff.cuni.cz/repository/xmlui/page/' +# String which will be replaced instead of OLD_LICENSE_DEFINITION_STRING +NEW_LICENSE_DEFINITION_STRING = FE_url + '/static/' + class ItemType(enum.Enum): ITEM = 1 diff --git a/data_pump/license.py b/data_pump/license.py index 7bc06bd..d2b01ac 100644 --- a/data_pump/license.py +++ b/data_pump/license.py @@ -1,9 +1,9 @@ import logging import os +from const import OLD_LICENSE_DEFINITION_STRING, NEW_LICENSE_DEFINITION_STRING from migration_const import ICON_PATH -from data_pump.utils import read_json, do_api_post, convert_response_to_json, \ - save_dict_as_json +from data_pump.utils import read_json, do_api_post, convert_response_to_json def import_license(eperson_id_dict, statistics_dict): @@ -77,7 +77,7 @@ def import_license(eperson_id_dict, statistics_dict): for license_ in license_json_list: license_json_p = { 'name': license_['name'], - 'definition': license_['definition'], + 'definition': update_license_definition(license_['definition']), 'confirmation': license_['confirmation'], 'requiredInfo': license_['required_info'], 'clarinLicenseLabel': labels_dict[license_['label_id']] @@ -100,3 +100,17 @@ def import_license(eperson_id_dict, statistics_dict): statistics_dict['license_definition'] = statistics_val logging.info("License_label, Extended_mapping, License_definitions " "were successfully imported!") + + +def update_license_definition(current_license_definition: str): + """ + Replace license definition url from current site url to a new site url + e.g., from `https://lindat.mff.cuni.cz/repository/xmlui/page/licence-hamledt` + to `https://lindat.mff.cuni.cz/repository/static/licence-hamledt.html` + """ + # Replace old site url to a new site url + new_license_definition = current_license_definition.replace(OLD_LICENSE_DEFINITION_STRING, + NEW_LICENSE_DEFINITION_STRING) + # File name has a missing `.html` suffix -> add that suffix to the end of the definition url + new_license_definition = new_license_definition + '.html' + return new_license_definition