oarepo-runtime 1.10.1__py3-none-any.whl → 1.10.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,17 @@
1
+ import re
1
2
  from functools import partial
2
3
 
3
4
  import marshmallow as ma
5
+ from invenio_access.permissions import system_identity
6
+ from invenio_i18n import gettext as _
4
7
  from invenio_i18n.selectors import get_locale
5
- from invenio_rdm_records.services.schemas.metadata import record_identifiers_schemes
8
+ from invenio_rdm_records.services.schemas.metadata import (
9
+ CreatorSchema,
10
+ record_identifiers_schemes,
11
+ )
6
12
  from invenio_rdm_records.services.schemas.tombstone import DeletionStatusSchema
7
13
  from invenio_rdm_records.services.schemas.versions import VersionsSchema
14
+ from invenio_records_resources.proxies import current_service_registry
8
15
  from invenio_vocabularies.contrib.awards.schema import AwardRelationSchema
9
16
  from invenio_vocabularies.contrib.funders.schema import FunderRelationSchema
10
17
  from marshmallow import fields as ma_fields
@@ -49,7 +56,7 @@ class RecordIdentifierField(IdentifierSet):
49
56
  partial(IdentifierSchema, allowed_schemes=record_identifiers_schemes)
50
57
  ),
51
58
  *args,
52
- **kwargs
59
+ **kwargs,
53
60
  )
54
61
 
55
62
 
@@ -60,7 +67,7 @@ class RelatedRecordIdentifierField(IdentifierSet):
60
67
  partial(IdentifierSchema, allowed_schemes=record_identifiers_schemes)
61
68
  ),
62
69
  *args,
63
- **kwargs
70
+ **kwargs,
64
71
  )
65
72
 
66
73
 
@@ -73,3 +80,67 @@ class RDMSubjectSchema(ma.Schema):
73
80
  _id = ma.fields.String(data_key="id")
74
81
 
75
82
  subject = MultilingualField()
83
+
84
+
85
+ class RDMNTKCreatorsSchema(CreatorSchema):
86
+ """NTK version of RDM creators schema.
87
+
88
+ This version makes sure that organizations are selected from the
89
+ list of organizations in the system. Record will not be valid if
90
+ organization is not in the system.
91
+ """
92
+
93
+ @ma.validates_schema
94
+ def check_organization_or_affiliation(self, data, **kwargs):
95
+ """Check if organization is in the system."""
96
+ person_or_org = data.get("person_or_org", {})
97
+ if person_or_org.get("type") == "personal":
98
+ affiliations = data.get("affiliations", [])
99
+ for affiliation in affiliations:
100
+ if not self.from_vocabulary(affiliation):
101
+ raise ma.ValidationError(
102
+ _(
103
+ "It is necessary to choose organization from the controlled vocabulary. "
104
+ "To add organization, please go to "
105
+ "https://nusl.techlib.cz/cs/migrace-nusl/navrh-novych-hesel/"
106
+ ),
107
+ field_name="affiliations",
108
+ )
109
+ else:
110
+ # organization
111
+ name = person_or_org.get("name")
112
+ affiliations = current_service_registry.get("affiliations")
113
+ found = [
114
+ x["name"]
115
+ for x in affiliations.search(
116
+ system_identity,
117
+ q=f'name.suggest:"{escape_opensearch_query(name)}"',
118
+ size=100,
119
+ ).hits
120
+ ]
121
+ if name not in found:
122
+ raise ma.ValidationError(
123
+ _(
124
+ "It is necessary to choose organization from the controlled vocabulary. "
125
+ "To add organization, please go to "
126
+ "https://nusl.techlib.cz/cs/migrace-nusl/navrh-novych-hesel/"
127
+ ),
128
+ field_name="person_or_org",
129
+ )
130
+ return data
131
+
132
+ def from_vocabulary(self, affiliation):
133
+ """Check if affiliation is from the vocabulary."""
134
+ if "id" not in affiliation:
135
+ return False
136
+ return True
137
+
138
+
139
+ def escape_opensearch_query(value: str) -> str:
140
+ """
141
+ Escapes special characters in a string for safe use in OpenSearch query syntax.
142
+ """
143
+ # Escape each special character with a backslash
144
+ escaped = re.sub(r'([\\+\-=&|><!(){}\[\]^"~*?:/])', r"\\\1", value)
145
+
146
+ return escaped
@@ -16,7 +16,7 @@ from invenio_rdm_records.services.schemas.parent import RDMParentSchema
16
16
  from invenio_rdm_records.services.schemas.pids import PIDSchema
17
17
  from invenio_rdm_records.services.schemas.record import validate_scheme
18
18
  from invenio_rdm_records.services.schemas.versions import VersionsSchema
19
- from marshmallow.fields import Dict, Nested
19
+ from marshmallow.fields import Dict, Nested, Raw
20
20
  from marshmallow_utils.fields import (
21
21
  BabelGettextDictField,
22
22
  FormatDate,
@@ -239,6 +239,8 @@ class InvenioRDMUISchema(InvenioUISchema, RDMBaseRecordSchema):
239
239
  values=Nested(PIDSchema),
240
240
  )
241
241
  parent = ma.fields.Nested(InvenioRDMParentUISchema)
242
+ access = ma.fields.Raw(attribute="access", data_key="access", dump_only=True)
243
+ files = ma.fields.Raw(attribute="files", data_key="files", dump_only=True)
242
244
 
243
245
  def hide_tombstone(self, data):
244
246
  """Hide tombstone info if the record isn't deleted and metadata if it is."""
@@ -83,3 +83,13 @@ msgstr ""
83
83
  #: /Users/m/w/cesnet/oarepo-runtime/oarepo_runtime/services/schema/i18n.py:28
84
84
  msgid "Both language and text must be provided."
85
85
  msgstr "Musí být vyplněn jazyk i hodnota."
86
+
87
+ #: /Users/m/w/cesnet/oarepo-runtime/oarepo_runtime/services/schema/rdm.py:103
88
+ #: /Users/m/w/cesnet/oarepo-runtime/oarepo_runtime/services/schema/rdm.py:127
89
+ msgid ""
90
+ "It is necessary to choose organization from the controlled vocabulary. To "
91
+ "add organization, please go to https://nusl.techlib.cz/cs/migrace-"
92
+ "nusl/navrh-novych-hesel/"
93
+ msgstr ""
94
+ "Organizaci je nutné vybrat ze slovníku. Pro doplnění nové, vyplňte formulář "
95
+ "na https://nusl.techlib.cz/cs/migrace-nusl/navrh-novych-hesel/"
@@ -87,3 +87,11 @@ msgstr ""
87
87
  #: /Users/m/w/cesnet/oarepo-runtime/oarepo_runtime/services/schema/i18n.py:28
88
88
  msgid "Both language and text must be provided."
89
89
  msgstr ""
90
+
91
+ #: /Users/m/w/cesnet/oarepo-runtime/oarepo_runtime/services/schema/rdm.py:103
92
+ #: /Users/m/w/cesnet/oarepo-runtime/oarepo_runtime/services/schema/rdm.py:127
93
+ msgid ""
94
+ "It is necessary to choose organization from the controlled vocabulary. To "
95
+ "add organization, please go to https://nusl.techlib.cz/cs/migrace-"
96
+ "nusl/navrh-novych-hesel/"
97
+ msgstr ""
@@ -8,7 +8,7 @@ msgid ""
8
8
  msgstr ""
9
9
  "Project-Id-Version: PROJECT VERSION\n"
10
10
  "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
11
- "POT-Creation-Date: 2025-07-29 15:53+0200\n"
11
+ "POT-Creation-Date: 2025-08-05 11:53+0200\n"
12
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -53,9 +53,18 @@ msgid "Version"
53
53
  msgstr ""
54
54
 
55
55
  #: /Users/m/w/cesnet/oarepo-runtime/oarepo_runtime/services/schema/i18n.py:28
56
+ #: /Users/m/w/cesnet/oarepo-runtime/oarepo_runtime/services/schema/i18n.py:29
56
57
  msgid "Both language and text must be provided."
57
58
  msgstr ""
58
59
 
60
+ #: /Users/m/w/cesnet/oarepo-runtime/oarepo_runtime/services/schema/rdm.py:103
61
+ #: /Users/m/w/cesnet/oarepo-runtime/oarepo_runtime/services/schema/rdm.py:127
62
+ msgid ""
63
+ "It is necessary to choose organization from the controlled vocabulary. To"
64
+ " add organization, please go to https://nusl.techlib.cz/cs/migrace-nusl"
65
+ "/navrh-novych-hesel/"
66
+ msgstr ""
67
+
59
68
  #: /Users/m/w/cesnet/oarepo-runtime/oarepo_runtime/services/schema/ui.py:155
60
69
  msgid "True"
61
70
  msgstr ""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oarepo-runtime
3
- Version: 1.10.1
3
+ Version: 1.10.3
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -136,28 +136,28 @@ oarepo_runtime/services/schema/marshmallow.py,sha256=iAMMH5MlYs59qetXAHOROvERNSc
136
136
  oarepo_runtime/services/schema/marshmallow_to_json_schema.py,sha256=VYLnVWHOoaxWCD_gqJO8-8u1SbaPEFBjDZ5HGgGr0Ow,2027
137
137
  oarepo_runtime/services/schema/oneofschema.py,sha256=GnWH4Or_G5M0NgSmCoqMI6PBrJg5AC9RHrcB5QDKRq0,6661
138
138
  oarepo_runtime/services/schema/polymorphic.py,sha256=bAbUoTIeDBiJPYPhpLEKKZekEdkHlpqkmNxk1hN3PDw,564
139
- oarepo_runtime/services/schema/rdm.py,sha256=rtyO46CREmBJMQxgm0UenIbELSY6OAj35VbxFflIH_g,2272
139
+ oarepo_runtime/services/schema/rdm.py,sha256=tfikqat-I3PH_WOIJSKOruPSlKn2uX8NSG-yqz8ch9w,4952
140
140
  oarepo_runtime/services/schema/rdm_ui.py,sha256=ffjl20tvRcuX3FNINOhGJWX84aTNEzJOqoKZum1s03s,3778
141
- oarepo_runtime/services/schema/ui.py,sha256=ff2AfK-G0fArlVHHKsDagPhu9NkMj6DPcVK4NycEO8c,8216
141
+ oarepo_runtime/services/schema/ui.py,sha256=GXOAXF1ZaMU4NPkER-Xrq_xtRfblr5SzZDOZ4snbCh0,8382
142
142
  oarepo_runtime/services/schema/validation.py,sha256=aRfeR-2D1XXYqI3_U5FHoFvJrYjZlpM8nB35-M_u3Qs,2300
143
143
  oarepo_runtime/translations/default_translations.py,sha256=060GBlA1ghWxfeumo6NqxCCZDb-6OezOuF6pr-_GEOQ,104
144
- oarepo_runtime/translations/messages.pot,sha256=7Sf8l_70GjmKnXKYioUFp8Z65qtW57BgR9N9NlwmiNU,3013
145
- oarepo_runtime/translations/cs/LC_MESSAGES/messages.mo,sha256=OxKvpWhjhv6WfhamLBrJ315vq7w1qVAhDoWRIk1qhAc,1138
146
- oarepo_runtime/translations/cs/LC_MESSAGES/messages.po,sha256=BtgVxnFb2xMl0j5vnSDHjQmTnDfuV5zEqcwJpHs9bTc,2568
144
+ oarepo_runtime/translations/messages.pot,sha256=Erv-fsNpX846dTWRsJrNui_40vmHPuSNWX0DDZvekKs,3440
145
+ oarepo_runtime/translations/cs/LC_MESSAGES/messages.mo,sha256=NB-_iWSXHDZNQ8P53MRkq4NmGOdaYqufaKTVO2QVNBA,1466
146
+ oarepo_runtime/translations/cs/LC_MESSAGES/messages.po,sha256=b8aRnPdDGED2WaDDzQlE2xSrPIB7vI_xpVhNr_Sl5e0,3069
147
147
  oarepo_runtime/translations/en/LC_MESSAGES/messages.mo,sha256=tq5pTCpH7cuzdwrQlpTMjS1jlnoV0dWDlK9mGcKT338,673
148
- oarepo_runtime/translations/en/LC_MESSAGES/messages.po,sha256=oWFA5kjT-sBNoZ3UIzYS03GQOvri5VqL9NcYnQnYsyQ,2562
148
+ oarepo_runtime/translations/en/LC_MESSAGES/messages.po,sha256=XzuYdpAjXrd_LOiYpQJEcSPwUk94FlpAnuSyO4adAmE,2911
149
149
  oarepo_runtime/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
150
150
  oarepo_runtime/utils/functools.py,sha256=gKS9YZtlIYcDvdNA9cmYO00yjiXBYV1jg8VpcRUyQyg,1324
151
151
  oarepo_runtime/utils/identity_utils.py,sha256=a8nnvkX_Am9iibLa82_iK-3agIl11LTxjiy5qPKBoT4,1183
152
152
  oarepo_runtime/utils/index.py,sha256=ArrUUXB-KowUcUksRKqcFpmqct4bn9alO1zd_kX2tmU,292
153
153
  oarepo_runtime/utils/path.py,sha256=V1NVyk3m12_YLbj7QHYvUpE1wScO78bYsX1LOLeXDkI,3108
154
- oarepo_runtime-1.10.1.dist-info/licenses/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
154
+ oarepo_runtime-1.10.3.dist-info/licenses/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
155
155
  tests/marshmallow_to_json/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
156
156
  tests/marshmallow_to_json/test_datacite_ui_schema.py,sha256=82iLj8nW45lZOUewpWbLX3mpSkpa9lxo-vK-Qtv_1bU,48552
157
157
  tests/marshmallow_to_json/test_simple_schema.py,sha256=izZN9p0v6kovtSZ6AdxBYmK_c6ZOti2_z_wPT_zXIr0,1500
158
158
  tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
159
- oarepo_runtime-1.10.1.dist-info/METADATA,sha256=zCwp5S-_WPbVncdCa2Ceonl39ixjvE1YYIaacrXgW20,4789
160
- oarepo_runtime-1.10.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
161
- oarepo_runtime-1.10.1.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
162
- oarepo_runtime-1.10.1.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
163
- oarepo_runtime-1.10.1.dist-info/RECORD,,
159
+ oarepo_runtime-1.10.3.dist-info/METADATA,sha256=rZfL4RhgaBADpTcJCK0iIOSVfnUzh4_CD2o3Yv1ayXA,4789
160
+ oarepo_runtime-1.10.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
161
+ oarepo_runtime-1.10.3.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
162
+ oarepo_runtime-1.10.3.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
163
+ oarepo_runtime-1.10.3.dist-info/RECORD,,