From d21c06792f3ab3ea952771841a8e3d4e8e577d96 Mon Sep 17 00:00:00 2001 From: Yugay Vasiliy Date: Tue, 16 Jul 2024 09:19:19 +0000 Subject: [PATCH 1/2] Authorized scopes are included in Fragment Schema --- ebl/fragmentarium/web/dtos.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/ebl/fragmentarium/web/dtos.py b/ebl/fragmentarium/web/dtos.py index 6c627ec8f..9b4d8c396 100644 --- a/ebl/fragmentarium/web/dtos.py +++ b/ebl/fragmentarium/web/dtos.py @@ -15,9 +15,6 @@ class FragmentDtoSchema(FragmentSchema): ) references = fields.Nested(ApiReferenceSchema, many=True) - class Meta: - exclude = ("authorized_scopes",) - def create_response_dto(fragment: Fragment, user: User, has_photo: bool): return FragmentDtoSchema(context={"user": user, "has_photo": has_photo}).dump( From 90ea42994879cb256752c7e8c232bd0cf3523b0d Mon Sep 17 00:00:00 2001 From: Yugay Vasiliy Date: Tue, 3 Sep 2024 11:07:34 +0000 Subject: [PATCH 2/2] feat(Fragment): add ocredSigns field --- ebl/fragmentarium/application/fragment_schema.py | 1 + ebl/fragmentarium/domain/fragment.py | 1 + ebl/fragmentarium/infrastructure/mongo_fragment_repository.py | 1 + ebl/tests/alignment/test_named_sequence.py | 3 ++- ebl/tests/factories/fragment.py | 2 ++ ebl/tests/fragmentarium/test_dtos.py | 1 + ebl/tests/fragmentarium/test_fragment_repository.py | 1 + 7 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ebl/fragmentarium/application/fragment_schema.py b/ebl/fragmentarium/application/fragment_schema.py index a490dd89f..7169c9efe 100644 --- a/ebl/fragmentarium/application/fragment_schema.py +++ b/ebl/fragmentarium/application/fragment_schema.py @@ -204,6 +204,7 @@ class FragmentSchema(Schema): ScopeField(), data_key="authorizedScopes", ) + ocr_signs = fields.String(load_default="", data_key="ocredSigns") introduction = fields.Nested(IntroductionSchema, default=Introduction()) script = fields.Nested(ScriptSchema, load_default=Script()) external_numbers = fields.Nested( diff --git a/ebl/fragmentarium/domain/fragment.py b/ebl/fragmentarium/domain/fragment.py index 69acc983b..4d640ea18 100644 --- a/ebl/fragmentarium/domain/fragment.py +++ b/ebl/fragmentarium/domain/fragment.py @@ -134,6 +134,7 @@ class Fragment: folios: Folios = Folios() text: Text = Text() signs: str = "" + ocr_signs: str = "" notes: Notes = Notes() references: Sequence[Reference] = () uncurated_references: Optional[Sequence[UncuratedReference]] = None diff --git a/ebl/fragmentarium/infrastructure/mongo_fragment_repository.py b/ebl/fragmentarium/infrastructure/mongo_fragment_repository.py index 3165a3c76..99ee02ba3 100644 --- a/ebl/fragmentarium/infrastructure/mongo_fragment_repository.py +++ b/ebl/fragmentarium/infrastructure/mongo_fragment_repository.py @@ -92,6 +92,7 @@ def update_field(self, field, fragment): "authorized_scopes": [ "authorized_scopes", ], + "ocredSigns": ("ocredSigns"), } if field not in fields_to_update: diff --git a/ebl/tests/alignment/test_named_sequence.py b/ebl/tests/alignment/test_named_sequence.py index 273a72f55..d81e9a2c3 100644 --- a/ebl/tests/alignment/test_named_sequence.py +++ b/ebl/tests/alignment/test_named_sequence.py @@ -4,6 +4,7 @@ from ebl.tests.factories.fragment import FragmentFactory signs = "X X ABZ001\nABZ002\nX X X\n" +ocr_signs = "" sequence = Sequence(["ABZ001", "#", "ABZ002", "#", "#"]) @@ -18,7 +19,7 @@ def test_of_signs() -> None: def test_of_fragment() -> None: vocabulary = Vocabulary() - fragment = FragmentFactory.build(signs=signs) + fragment = FragmentFactory.build(signs=signs, ocr_signs=ocr_signs) named = NamedSequence.of_fragment(fragment, vocabulary) assert named.name == str(fragment.number) diff --git a/ebl/tests/factories/fragment.py b/ebl/tests/factories/fragment.py index ae33d144c..cebe217a6 100644 --- a/ebl/tests/factories/fragment.py +++ b/ebl/tests/factories/fragment.py @@ -236,6 +236,7 @@ class Meta: projects = (ResearchProject.CAIC,) archaeology = factory.SubFactory(ArchaeologyFactory) colophon = factory.SubFactory(ColophonFactory) + ocr_signs = "ABZ10 X" class InterestingFragmentFactory(FragmentFactory): @@ -454,6 +455,7 @@ class TransliteratedFragmentFactory(FragmentFactory): "X MU TA MA UD\n" "ŠU/|BI×IS|" ) + ocr_signs = "ABZ10 X" folios = Folios((Folio("WGL", "3"), Folio("ARG", "3"))) record = Record((RecordEntry("test", RecordType.TRANSLITERATION),)) line_to_vec = ( diff --git a/ebl/tests/fragmentarium/test_dtos.py b/ebl/tests/fragmentarium/test_dtos.py index 78fe42418..52682d8f8 100644 --- a/ebl/tests/fragmentarium/test_dtos.py +++ b/ebl/tests/fragmentarium/test_dtos.py @@ -117,6 +117,7 @@ def expected_dto(lemmatized_fragment, has_photo): "archaeology": ArchaeologySchema().dump(lemmatized_fragment.archaeology), "colophon": ColophonSchema().dump(lemmatized_fragment.colophon), "authorizedScopes": [], + "ocredSigns": "ABZ10 X", }, pydash.is_none, ) diff --git a/ebl/tests/fragmentarium/test_fragment_repository.py b/ebl/tests/fragmentarium/test_fragment_repository.py index 892e2df79..31f45e33a 100644 --- a/ebl/tests/fragmentarium/test_fragment_repository.py +++ b/ebl/tests/fragmentarium/test_fragment_repository.py @@ -96,6 +96,7 @@ ) ), signs="MI DIŠ DIŠ UD ŠU", + ocr_signs="", )