oarepo-runtime 1.10.3__py3-none-any.whl → 1.10.4__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.
- oarepo_runtime/services/schema/rdm.py +2 -73
- {oarepo_runtime-1.10.3.dist-info → oarepo_runtime-1.10.4.dist-info}/METADATA +1 -1
- {oarepo_runtime-1.10.3.dist-info → oarepo_runtime-1.10.4.dist-info}/RECORD +7 -7
- {oarepo_runtime-1.10.3.dist-info → oarepo_runtime-1.10.4.dist-info}/WHEEL +0 -0
- {oarepo_runtime-1.10.3.dist-info → oarepo_runtime-1.10.4.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-1.10.3.dist-info → oarepo_runtime-1.10.4.dist-info}/licenses/LICENSE +0 -0
- {oarepo_runtime-1.10.3.dist-info → oarepo_runtime-1.10.4.dist-info}/top_level.txt +0 -0
@@ -1,17 +1,10 @@
|
|
1
|
-
import re
|
2
1
|
from functools import partial
|
3
2
|
|
4
3
|
import marshmallow as ma
|
5
|
-
from invenio_access.permissions import system_identity
|
6
|
-
from invenio_i18n import gettext as _
|
7
4
|
from invenio_i18n.selectors import get_locale
|
8
|
-
from invenio_rdm_records.services.schemas.metadata import
|
9
|
-
CreatorSchema,
|
10
|
-
record_identifiers_schemes,
|
11
|
-
)
|
5
|
+
from invenio_rdm_records.services.schemas.metadata import record_identifiers_schemes
|
12
6
|
from invenio_rdm_records.services.schemas.tombstone import DeletionStatusSchema
|
13
7
|
from invenio_rdm_records.services.schemas.versions import VersionsSchema
|
14
|
-
from invenio_records_resources.proxies import current_service_registry
|
15
8
|
from invenio_vocabularies.contrib.awards.schema import AwardRelationSchema
|
16
9
|
from invenio_vocabularies.contrib.funders.schema import FunderRelationSchema
|
17
10
|
from marshmallow import fields as ma_fields
|
@@ -79,68 +72,4 @@ class RDMSubjectSchema(ma.Schema):
|
|
79
72
|
|
80
73
|
_id = ma.fields.String(data_key="id")
|
81
74
|
|
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
|
75
|
+
subject = MultilingualField()
|
@@ -136,7 +136,7 @@ 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=
|
139
|
+
oarepo_runtime/services/schema/rdm.py,sha256=TwUuxxHeJZFFptMAfEcquaO-7ss6GBSlNoLDzmy53Ek,2273
|
140
140
|
oarepo_runtime/services/schema/rdm_ui.py,sha256=ffjl20tvRcuX3FNINOhGJWX84aTNEzJOqoKZum1s03s,3778
|
141
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
|
@@ -151,13 +151,13 @@ oarepo_runtime/utils/functools.py,sha256=gKS9YZtlIYcDvdNA9cmYO00yjiXBYV1jg8VpcRU
|
|
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.
|
154
|
+
oarepo_runtime-1.10.4.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.
|
160
|
-
oarepo_runtime-1.10.
|
161
|
-
oarepo_runtime-1.10.
|
162
|
-
oarepo_runtime-1.10.
|
163
|
-
oarepo_runtime-1.10.
|
159
|
+
oarepo_runtime-1.10.4.dist-info/METADATA,sha256=-wlvwmix8KBfIQlEbtsRnyuuG4Ff4Wiug2cqY90JG70,4789
|
160
|
+
oarepo_runtime-1.10.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
161
|
+
oarepo_runtime-1.10.4.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
|
162
|
+
oarepo_runtime-1.10.4.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
|
163
|
+
oarepo_runtime-1.10.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|