From e63ee1966c06430d5932fe770565ff7919d61074 Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Tue, 13 Feb 2024 10:03:54 -0300 Subject: [PATCH] iiif: moving iiif and fixing bugs --- geo_rdm_records/__init__.py | 2 +- geo_rdm_records/config.py | 2 +- .../{rdm/services => }/iiif/__init__.py | 2 +- .../modules/{rdm/services => }/iiif/service.py | 18 ++++++++---------- 4 files changed, 11 insertions(+), 13 deletions(-) rename geo_rdm_records/modules/{rdm/services => }/iiif/__init__.py (83%) rename geo_rdm_records/modules/{rdm/services => }/iiif/service.py (86%) diff --git a/geo_rdm_records/__init__.py b/geo_rdm_records/__init__.py index b445a4c..bce0bd3 100644 --- a/geo_rdm_records/__init__.py +++ b/geo_rdm_records/__init__.py @@ -9,5 +9,5 @@ from .ext import GEORDMRecords -__version__ = "0.8.0.dev0" +__version__ = "0.8.0.dev1" __all__ = ("__version__", "GEORDMRecords") diff --git a/geo_rdm_records/config.py b/geo_rdm_records/config.py index 561942a..0a672de 100644 --- a/geo_rdm_records/config.py +++ b/geo_rdm_records/config.py @@ -64,7 +64,7 @@ RDM_REVIEW_SERVICE = "geo_rdm_records.modules.rdm.services.review.service.ReviewService" -RDM_IIIF_SERVICE = "geo_rdm_records.modules.rdm.services.iiif.service.IIIFService" +RDM_IIIF_SERVICE = "geo_rdm_records.modules.iiif.service.IIIFService" # Configuration RDM_RECORD_SERVICE_CFG = ( diff --git a/geo_rdm_records/modules/rdm/services/iiif/__init__.py b/geo_rdm_records/modules/iiif/__init__.py similarity index 83% rename from geo_rdm_records/modules/rdm/services/iiif/__init__.py rename to geo_rdm_records/modules/iiif/__init__.py index 78ce79f..9cbbd0c 100644 --- a/geo_rdm_records/modules/rdm/services/iiif/__init__.py +++ b/geo_rdm_records/modules/iiif/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2022 Geo Secretariat. +# Copyright (C) 2022-2024 GEO Secretariat. # # geo-rdm-records is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. diff --git a/geo_rdm_records/modules/rdm/services/iiif/service.py b/geo_rdm_records/modules/iiif/service.py similarity index 86% rename from geo_rdm_records/modules/rdm/services/iiif/service.py rename to geo_rdm_records/modules/iiif/service.py index 7dd7103..3cdbf06 100644 --- a/geo_rdm_records/modules/rdm/services/iiif/service.py +++ b/geo_rdm_records/modules/iiif/service.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2022 Geo Secretariat. +# Copyright (C) 2022-2024 GEO Secretariat. # # geo-rdm-records is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. @@ -14,12 +14,7 @@ class IIIFService(BaseIIIFService): - """IIIF service. - - ToDo: - We are just starting with this component. In a near future we will - revise this approach to improve the way we delivery IIIF APIs. - """ + """IIIF service.""" modes = {"record": ["record", "draft"], "package": ["package", "package-draft"]} """Service operation mode.""" @@ -48,7 +43,7 @@ def _get_mode_type(self, type_): mode_types = self.modes_type[mode] for mode_type in mode_types: - if mode in mode_types[mode_type]: + if type_ in mode_types[mode_type]: return mode_type def _get_service(self, type_): @@ -59,7 +54,7 @@ def _get_service(self, type_): def file_service(self, type_): """Get the correct instance of the file service, draft vs record.""" service = self._get_service(type_) - mode_type = self._get_mode(type_) + mode_type = self._get_mode_type(type_) return service.files if mode_type == "record" else service.draft_files @@ -69,11 +64,14 @@ def read_record(self, identity, uuid): # Defining the operation mode of the service. service = self._get_service(type_) - mode_type = self._get_mode(type_) + mode_type = self._get_mode_type(type_) read = service.read if mode_type == "record" else service.read_draft record = read(identity=identity, id_=id_) + file_service = self.file_service(type_) files = file_service.list_files(identity=identity, id_=id_) + record.files = files + return record