oarepo-runtime 1.5.127__py3-none-any.whl → 1.5.129__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/records/drafts.py +42 -0
- oarepo_runtime/records/mappings/rdm_parent_mapping.json +450 -6
- oarepo_runtime/resources/responses.py +12 -1
- oarepo_runtime/services/config/__init__.py +4 -0
- oarepo_runtime/services/config/draft_link.py +23 -0
- oarepo_runtime/services/config/link_conditions.py +19 -1
- oarepo_runtime/services/schema/ui.py +15 -7
- oarepo_runtime/services/schema/validation.py +9 -5
- {oarepo_runtime-1.5.127.dist-info → oarepo_runtime-1.5.129.dist-info}/METADATA +1 -1
- {oarepo_runtime-1.5.127.dist-info → oarepo_runtime-1.5.129.dist-info}/RECORD +14 -12
- {oarepo_runtime-1.5.127.dist-info → oarepo_runtime-1.5.129.dist-info}/LICENSE +0 -0
- {oarepo_runtime-1.5.127.dist-info → oarepo_runtime-1.5.129.dist-info}/WHEEL +0 -0
- {oarepo_runtime-1.5.127.dist-info → oarepo_runtime-1.5.129.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-1.5.127.dist-info → oarepo_runtime-1.5.129.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
from invenio_records_resources.records.api import Record
|
2
|
+
|
3
|
+
from oarepo_runtime.datastreams.utils import get_record_service_for_record
|
4
|
+
|
5
|
+
|
6
|
+
def has_draft(record: Record) -> bool:
|
7
|
+
return get_draft(record) is not None
|
8
|
+
|
9
|
+
|
10
|
+
def get_draft(record: Record) -> Record | None:
|
11
|
+
"""Get the draft of a published record, if it exists.
|
12
|
+
|
13
|
+
A record can have a draft if:
|
14
|
+
|
15
|
+
- it has a parent record (so, for vocabulary records, this will always be False)
|
16
|
+
- if it has a has_draft attribute (that means, it is a published record)
|
17
|
+
- the has_draft is True meaning that the record has a draft ('edit metadata' button)
|
18
|
+
- if the record has a parent and the parent has a draft (edited 'new version' of the record)
|
19
|
+
"""
|
20
|
+
if getattr(record, "is_draft", False):
|
21
|
+
return record
|
22
|
+
if not hasattr(record, "parent"):
|
23
|
+
return None
|
24
|
+
if not hasattr(record, "has_draft"):
|
25
|
+
return None
|
26
|
+
|
27
|
+
record_service = get_record_service_for_record(record)
|
28
|
+
if not record_service:
|
29
|
+
return None
|
30
|
+
|
31
|
+
try:
|
32
|
+
# if there is no record service, we cannot check for draft
|
33
|
+
if not record_service:
|
34
|
+
return None
|
35
|
+
return next(
|
36
|
+
record_service.config.draft_cls.get_records_by_parent(
|
37
|
+
record.parent, with_deleted=False
|
38
|
+
)
|
39
|
+
)
|
40
|
+
except StopIteration:
|
41
|
+
# no draft found
|
42
|
+
return None
|
@@ -1,7 +1,4 @@
|
|
1
1
|
{
|
2
|
-
"is_verified": {
|
3
|
-
"type": "boolean"
|
4
|
-
},
|
5
2
|
"access": {
|
6
3
|
"properties": {
|
7
4
|
"owned_by": {
|
@@ -14,12 +11,19 @@
|
|
14
11
|
"grants": {
|
15
12
|
"properties": {
|
16
13
|
"subject": {
|
17
|
-
"
|
14
|
+
"properties": {
|
15
|
+
"type": {
|
16
|
+
"type": "keyword"
|
17
|
+
},
|
18
|
+
"id": {
|
19
|
+
"type": "keyword"
|
20
|
+
}
|
21
|
+
}
|
18
22
|
},
|
19
|
-
"
|
23
|
+
"permission": {
|
20
24
|
"type": "keyword"
|
21
25
|
},
|
22
|
-
"
|
26
|
+
"origin": {
|
23
27
|
"type": "keyword"
|
24
28
|
}
|
25
29
|
}
|
@@ -33,6 +37,446 @@
|
|
33
37
|
"type": "keyword"
|
34
38
|
}
|
35
39
|
}
|
40
|
+
},
|
41
|
+
"settings": {
|
42
|
+
"properties": {
|
43
|
+
"allow_user_requests": {
|
44
|
+
"type": "boolean"
|
45
|
+
},
|
46
|
+
"allow_guest_requests": {
|
47
|
+
"type": "boolean"
|
48
|
+
},
|
49
|
+
"accept_conditions_text": {
|
50
|
+
"type": "text"
|
51
|
+
},
|
52
|
+
"secret_link_expiration": {
|
53
|
+
"type": "integer"
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
},
|
59
|
+
"is_verified": {
|
60
|
+
"type": "boolean"
|
61
|
+
},
|
62
|
+
"communities": {
|
63
|
+
"properties": {
|
64
|
+
"ids": {
|
65
|
+
"type": "keyword"
|
66
|
+
},
|
67
|
+
"default": {
|
68
|
+
"type": "keyword"
|
69
|
+
},
|
70
|
+
"entries": {
|
71
|
+
"type": "object",
|
72
|
+
"properties": {
|
73
|
+
"uuid": {
|
74
|
+
"type": "keyword"
|
75
|
+
},
|
76
|
+
"created": {
|
77
|
+
"type": "date"
|
78
|
+
},
|
79
|
+
"updated": {
|
80
|
+
"type": "date"
|
81
|
+
},
|
82
|
+
"version_id": {
|
83
|
+
"type": "long"
|
84
|
+
},
|
85
|
+
"id": {
|
86
|
+
"type": "keyword"
|
87
|
+
},
|
88
|
+
"is_verified": {
|
89
|
+
"type": "boolean"
|
90
|
+
},
|
91
|
+
"@v": {
|
92
|
+
"type": "keyword"
|
93
|
+
},
|
94
|
+
"slug": {
|
95
|
+
"type": "keyword"
|
96
|
+
},
|
97
|
+
"children": {
|
98
|
+
"properties": {
|
99
|
+
"allow": {
|
100
|
+
"type": "boolean"
|
101
|
+
}
|
102
|
+
}
|
103
|
+
},
|
104
|
+
"metadata": {
|
105
|
+
"properties": {
|
106
|
+
"title": {
|
107
|
+
"type": "text"
|
108
|
+
},
|
109
|
+
"type": {
|
110
|
+
"type": "object",
|
111
|
+
"properties": {
|
112
|
+
"@v": {
|
113
|
+
"type": "keyword"
|
114
|
+
},
|
115
|
+
"id": {
|
116
|
+
"type": "keyword"
|
117
|
+
},
|
118
|
+
"title": {
|
119
|
+
"type": "object",
|
120
|
+
"dynamic": "true",
|
121
|
+
"properties": {
|
122
|
+
"en": {
|
123
|
+
"type": "text"
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
},
|
129
|
+
"organizations": {
|
130
|
+
"type": "object",
|
131
|
+
"properties": {
|
132
|
+
"@v": {
|
133
|
+
"type": "keyword"
|
134
|
+
},
|
135
|
+
"id": {
|
136
|
+
"type": "keyword"
|
137
|
+
},
|
138
|
+
"name": {
|
139
|
+
"type": "text"
|
140
|
+
},
|
141
|
+
"identifiers": {
|
142
|
+
"properties": {
|
143
|
+
"identifier": {
|
144
|
+
"type": "text",
|
145
|
+
"fields": {
|
146
|
+
"keyword": {
|
147
|
+
"type": "keyword"
|
148
|
+
}
|
149
|
+
}
|
150
|
+
},
|
151
|
+
"scheme": {
|
152
|
+
"type": "keyword"
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
}
|
157
|
+
},
|
158
|
+
"funding": {
|
159
|
+
"properties": {
|
160
|
+
"award": {
|
161
|
+
"type": "object",
|
162
|
+
"properties": {
|
163
|
+
"@v": {
|
164
|
+
"type": "keyword"
|
165
|
+
},
|
166
|
+
"id": {
|
167
|
+
"type": "keyword"
|
168
|
+
},
|
169
|
+
"title": {
|
170
|
+
"type": "object",
|
171
|
+
"dynamic": "true"
|
172
|
+
},
|
173
|
+
"number": {
|
174
|
+
"type": "text",
|
175
|
+
"fields": {
|
176
|
+
"keyword": {
|
177
|
+
"type": "keyword"
|
178
|
+
}
|
179
|
+
}
|
180
|
+
},
|
181
|
+
"program": {
|
182
|
+
"type": "keyword"
|
183
|
+
},
|
184
|
+
"acronym": {
|
185
|
+
"type": "keyword",
|
186
|
+
"fields": {
|
187
|
+
"text": {
|
188
|
+
"type": "text"
|
189
|
+
}
|
190
|
+
}
|
191
|
+
},
|
192
|
+
"identifiers": {
|
193
|
+
"properties": {
|
194
|
+
"identifier": {
|
195
|
+
"type": "keyword"
|
196
|
+
},
|
197
|
+
"scheme": {
|
198
|
+
"type": "keyword"
|
199
|
+
}
|
200
|
+
}
|
201
|
+
},
|
202
|
+
"subjects": {
|
203
|
+
"properties": {
|
204
|
+
"@v": {
|
205
|
+
"type": "keyword"
|
206
|
+
},
|
207
|
+
"id": {
|
208
|
+
"type": "keyword"
|
209
|
+
},
|
210
|
+
"subject": {
|
211
|
+
"type": "keyword"
|
212
|
+
},
|
213
|
+
"scheme": {
|
214
|
+
"type": "keyword"
|
215
|
+
},
|
216
|
+
"props": {
|
217
|
+
"type": "object",
|
218
|
+
"dynamic": "true"
|
219
|
+
}
|
220
|
+
}
|
221
|
+
},
|
222
|
+
"organizations": {
|
223
|
+
"properties": {
|
224
|
+
"scheme": {
|
225
|
+
"type": "keyword"
|
226
|
+
},
|
227
|
+
"id": {
|
228
|
+
"type": "keyword"
|
229
|
+
},
|
230
|
+
"organization": {
|
231
|
+
"type": "keyword"
|
232
|
+
}
|
233
|
+
}
|
234
|
+
}
|
235
|
+
}
|
236
|
+
},
|
237
|
+
"funder": {
|
238
|
+
"type": "object",
|
239
|
+
"properties": {
|
240
|
+
"@v": {
|
241
|
+
"type": "keyword"
|
242
|
+
},
|
243
|
+
"id": {
|
244
|
+
"type": "keyword"
|
245
|
+
},
|
246
|
+
"name": {
|
247
|
+
"type": "text"
|
248
|
+
}
|
249
|
+
}
|
250
|
+
}
|
251
|
+
}
|
252
|
+
},
|
253
|
+
"website": {
|
254
|
+
"type": "keyword"
|
255
|
+
}
|
256
|
+
}
|
257
|
+
},
|
258
|
+
"theme": {
|
259
|
+
"type": "object",
|
260
|
+
"properties": {
|
261
|
+
"enabled": {
|
262
|
+
"type": "boolean"
|
263
|
+
},
|
264
|
+
"brand": {
|
265
|
+
"type": "keyword"
|
266
|
+
},
|
267
|
+
"style": {
|
268
|
+
"type": "object",
|
269
|
+
"enabled": false
|
270
|
+
}
|
271
|
+
}
|
272
|
+
},
|
273
|
+
"parent": {
|
274
|
+
"type": "object",
|
275
|
+
"properties": {
|
276
|
+
"uuid": {
|
277
|
+
"type": "keyword"
|
278
|
+
},
|
279
|
+
"created": {
|
280
|
+
"type": "date"
|
281
|
+
},
|
282
|
+
"updated": {
|
283
|
+
"type": "date"
|
284
|
+
},
|
285
|
+
"version_id": {
|
286
|
+
"type": "long"
|
287
|
+
},
|
288
|
+
"id": {
|
289
|
+
"type": "keyword"
|
290
|
+
},
|
291
|
+
"@v": {
|
292
|
+
"type": "keyword"
|
293
|
+
},
|
294
|
+
"is_verified": {
|
295
|
+
"type": "boolean"
|
296
|
+
},
|
297
|
+
"slug": {
|
298
|
+
"type": "keyword"
|
299
|
+
},
|
300
|
+
"children": {
|
301
|
+
"properties": {
|
302
|
+
"allow": {
|
303
|
+
"type": "boolean"
|
304
|
+
}
|
305
|
+
}
|
306
|
+
},
|
307
|
+
"metadata": {
|
308
|
+
"type": "object",
|
309
|
+
"properties": {
|
310
|
+
"title": {
|
311
|
+
"type": "text"
|
312
|
+
},
|
313
|
+
"type": {
|
314
|
+
"type": "object",
|
315
|
+
"properties": {
|
316
|
+
"@v": {
|
317
|
+
"type": "keyword"
|
318
|
+
},
|
319
|
+
"id": {
|
320
|
+
"type": "keyword"
|
321
|
+
},
|
322
|
+
"title": {
|
323
|
+
"type": "object",
|
324
|
+
"dynamic": "true",
|
325
|
+
"properties": {
|
326
|
+
"en": {
|
327
|
+
"type": "text"
|
328
|
+
}
|
329
|
+
}
|
330
|
+
}
|
331
|
+
}
|
332
|
+
},
|
333
|
+
"website": {
|
334
|
+
"type": "keyword"
|
335
|
+
},
|
336
|
+
"organizations": {
|
337
|
+
"type": "object",
|
338
|
+
"properties": {
|
339
|
+
"@v": {
|
340
|
+
"type": "keyword"
|
341
|
+
},
|
342
|
+
"id": {
|
343
|
+
"type": "keyword"
|
344
|
+
},
|
345
|
+
"name": {
|
346
|
+
"type": "text"
|
347
|
+
},
|
348
|
+
"identifiers": {
|
349
|
+
"properties": {
|
350
|
+
"identifier": {
|
351
|
+
"type": "text",
|
352
|
+
"fields": {
|
353
|
+
"keyword": {
|
354
|
+
"type": "keyword"
|
355
|
+
}
|
356
|
+
}
|
357
|
+
},
|
358
|
+
"scheme": {
|
359
|
+
"type": "keyword"
|
360
|
+
}
|
361
|
+
}
|
362
|
+
}
|
363
|
+
}
|
364
|
+
},
|
365
|
+
"funding": {
|
366
|
+
"properties": {
|
367
|
+
"award": {
|
368
|
+
"type": "object",
|
369
|
+
"properties": {
|
370
|
+
"@v": {
|
371
|
+
"type": "keyword"
|
372
|
+
},
|
373
|
+
"id": {
|
374
|
+
"type": "keyword"
|
375
|
+
},
|
376
|
+
"title": {
|
377
|
+
"type": "object",
|
378
|
+
"dynamic": "true"
|
379
|
+
},
|
380
|
+
"number": {
|
381
|
+
"type": "text",
|
382
|
+
"fields": {
|
383
|
+
"keyword": {
|
384
|
+
"type": "keyword"
|
385
|
+
}
|
386
|
+
}
|
387
|
+
},
|
388
|
+
"program": {
|
389
|
+
"type": "keyword"
|
390
|
+
},
|
391
|
+
"acronym": {
|
392
|
+
"type": "keyword",
|
393
|
+
"fields": {
|
394
|
+
"text": {
|
395
|
+
"type": "text"
|
396
|
+
}
|
397
|
+
}
|
398
|
+
},
|
399
|
+
"identifiers": {
|
400
|
+
"properties": {
|
401
|
+
"identifier": {
|
402
|
+
"type": "keyword"
|
403
|
+
},
|
404
|
+
"scheme": {
|
405
|
+
"type": "keyword"
|
406
|
+
}
|
407
|
+
}
|
408
|
+
},
|
409
|
+
"subjects": {
|
410
|
+
"properties": {
|
411
|
+
"@v": {
|
412
|
+
"type": "keyword"
|
413
|
+
},
|
414
|
+
"id": {
|
415
|
+
"type": "keyword"
|
416
|
+
},
|
417
|
+
"subject": {
|
418
|
+
"type": "keyword"
|
419
|
+
},
|
420
|
+
"scheme": {
|
421
|
+
"type": "keyword"
|
422
|
+
},
|
423
|
+
"props": {
|
424
|
+
"type": "object",
|
425
|
+
"dynamic": "true"
|
426
|
+
}
|
427
|
+
}
|
428
|
+
},
|
429
|
+
"organizations": {
|
430
|
+
"properties": {
|
431
|
+
"scheme": {
|
432
|
+
"type": "keyword"
|
433
|
+
},
|
434
|
+
"id": {
|
435
|
+
"type": "keyword"
|
436
|
+
},
|
437
|
+
"organization": {
|
438
|
+
"type": "keyword"
|
439
|
+
}
|
440
|
+
}
|
441
|
+
}
|
442
|
+
}
|
443
|
+
},
|
444
|
+
"funder": {
|
445
|
+
"type": "object",
|
446
|
+
"properties": {
|
447
|
+
"@v": {
|
448
|
+
"type": "keyword"
|
449
|
+
},
|
450
|
+
"id": {
|
451
|
+
"type": "keyword"
|
452
|
+
},
|
453
|
+
"name": {
|
454
|
+
"type": "text"
|
455
|
+
}
|
456
|
+
}
|
457
|
+
}
|
458
|
+
}
|
459
|
+
}
|
460
|
+
}
|
461
|
+
},
|
462
|
+
"theme": {
|
463
|
+
"type": "object",
|
464
|
+
"properties": {
|
465
|
+
"enabled": {
|
466
|
+
"type": "boolean"
|
467
|
+
},
|
468
|
+
"brand": {
|
469
|
+
"type": "keyword"
|
470
|
+
},
|
471
|
+
"style": {
|
472
|
+
"type": "object",
|
473
|
+
"enabled": false
|
474
|
+
}
|
475
|
+
}
|
476
|
+
}
|
477
|
+
}
|
478
|
+
}
|
479
|
+
}
|
36
480
|
}
|
37
481
|
}
|
38
482
|
}
|
@@ -6,4 +6,15 @@ class ExportableResponseHandler(ResponseHandler):
|
|
6
6
|
"""Constructor."""
|
7
7
|
self.export_code = export_code
|
8
8
|
self.name = name
|
9
|
-
super().__init__(serializer, headers)
|
9
|
+
super().__init__(serializer, headers)
|
10
|
+
|
11
|
+
|
12
|
+
class OAIExportableResponseHandler(ExportableResponseHandler):
|
13
|
+
|
14
|
+
def __init__(self, serializer, export_code, name, oai_metadata_prefix, oai_schema, oai_namespace,
|
15
|
+
headers=None):
|
16
|
+
"""Constructor."""
|
17
|
+
self.oai_metadata_prefix = oai_metadata_prefix
|
18
|
+
self.oai_schema = oai_schema
|
19
|
+
self.oai_namespace = oai_namespace
|
20
|
+
super().__init__(serializer, export_code, name, headers)
|
@@ -1,5 +1,7 @@
|
|
1
|
+
from .draft_link import DraftLink
|
1
2
|
from .link_conditions import (
|
2
3
|
has_draft,
|
4
|
+
has_draft_permission,
|
3
5
|
has_file_permission,
|
4
6
|
has_permission,
|
5
7
|
has_permission_file_service,
|
@@ -28,4 +30,6 @@ __all__ = (
|
|
28
30
|
"has_permission_file_service",
|
29
31
|
"has_file_permission",
|
30
32
|
"has_published_record",
|
33
|
+
"has_draft_permission",
|
34
|
+
"DraftLink",
|
31
35
|
)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
from invenio_records_resources.services import RecordLink
|
2
|
+
|
3
|
+
from oarepo_runtime.records.drafts import get_draft
|
4
|
+
|
5
|
+
|
6
|
+
class DraftLink(RecordLink):
|
7
|
+
"""Draft link."""
|
8
|
+
|
9
|
+
def __init__(self, *args, **kwargs):
|
10
|
+
"""Initialize draft link."""
|
11
|
+
super().__init__(*args, **kwargs)
|
12
|
+
|
13
|
+
@staticmethod
|
14
|
+
def vars(record, vars):
|
15
|
+
"""Variables for the URI template."""
|
16
|
+
# Some records don't have record.pid.pid_value yet (e.g. drafts)
|
17
|
+
RecordLink.vars(record, vars)
|
18
|
+
draft_record = get_draft(record)
|
19
|
+
|
20
|
+
if draft_record:
|
21
|
+
pid_value = getattr(draft_record.pid, "pid_value", None)
|
22
|
+
if pid_value:
|
23
|
+
vars.update({"id": pid_value})
|
@@ -7,10 +7,10 @@ from invenio_records.api import RecordBase
|
|
7
7
|
from invenio_records_resources.records.api import FileRecord, Record
|
8
8
|
|
9
9
|
from ...datastreams.utils import (
|
10
|
-
get_file_service_for_file_record_class,
|
11
10
|
get_file_service_for_record_class,
|
12
11
|
get_record_service_for_record,
|
13
12
|
)
|
13
|
+
from ...records.drafts import get_draft
|
14
14
|
|
15
15
|
log = getLogger(__name__)
|
16
16
|
|
@@ -76,6 +76,24 @@ class has_permission(Condition):
|
|
76
76
|
log.exception(f"Unexpected exception {e}.")
|
77
77
|
|
78
78
|
|
79
|
+
class has_draft_permission(Condition):
|
80
|
+
def __init__(self, action_name):
|
81
|
+
self.action_name = action_name
|
82
|
+
|
83
|
+
def __call__(self, obj: RecordBase, ctx: dict):
|
84
|
+
draft_record = get_draft(obj)
|
85
|
+
if not draft_record:
|
86
|
+
return False
|
87
|
+
service = get_record_service_for_record(obj)
|
88
|
+
try:
|
89
|
+
return service.check_permission(
|
90
|
+
action_name=self.action_name, record=draft_record, **ctx
|
91
|
+
)
|
92
|
+
except Exception as e:
|
93
|
+
log.exception(f"Unexpected exception {e}.")
|
94
|
+
return False
|
95
|
+
|
96
|
+
|
79
97
|
class has_file_permission(has_permission):
|
80
98
|
def __call__(self, obj: RecordBase, ctx: dict):
|
81
99
|
if isinstance(obj, FileRecord):
|
@@ -2,27 +2,29 @@ import datetime
|
|
2
2
|
import re
|
3
3
|
|
4
4
|
import marshmallow as ma
|
5
|
-
from marshmallow.fields import Dict, Nested
|
6
|
-
from marshmallow_utils.fields import SanitizedUnicode
|
7
|
-
from invenio_rdm_records.services.schemas.pids import PIDSchema
|
8
5
|
from babel.dates import format_date
|
9
6
|
from babel_edtf import format_edtf
|
10
7
|
from flask import current_app
|
8
|
+
from idutils import to_url
|
11
9
|
from invenio_rdm_records.records.systemfields.access.field.record import (
|
12
10
|
AccessStatusEnum,
|
13
11
|
)
|
14
12
|
from invenio_rdm_records.resources.serializers.ui.fields import (
|
15
13
|
UIObjectAccessStatus as InvenioUIObjectAccessStatus,
|
16
14
|
)
|
15
|
+
from invenio_rdm_records.services.schemas.parent import RDMParentSchema
|
16
|
+
from invenio_rdm_records.services.schemas.pids import PIDSchema
|
17
|
+
from invenio_rdm_records.services.schemas.record import validate_scheme
|
17
18
|
from invenio_rdm_records.services.schemas.versions import VersionsSchema
|
19
|
+
from marshmallow.fields import Dict, Nested
|
18
20
|
from marshmallow_utils.fields import (
|
19
21
|
BabelGettextDictField,
|
20
22
|
FormatDate,
|
21
23
|
FormatDatetime,
|
22
24
|
FormatEDTF,
|
23
25
|
FormatTime,
|
26
|
+
SanitizedUnicode,
|
24
27
|
)
|
25
|
-
from invenio_rdm_records.services.schemas.parent import RDMParentSchema
|
26
28
|
from marshmallow_utils.fields.babel import BabelFormatField
|
27
29
|
|
28
30
|
from oarepo_runtime.i18n import gettext
|
@@ -30,9 +32,6 @@ from oarepo_runtime.i18n import lazy_gettext as _
|
|
30
32
|
|
31
33
|
from .marshmallow import RDMBaseRecordSchema
|
32
34
|
|
33
|
-
from invenio_rdm_records.services.schemas.record import validate_scheme
|
34
|
-
from idutils import to_url
|
35
|
-
|
36
35
|
|
37
36
|
def current_default_locale():
|
38
37
|
"""Get the Flask app's default locale."""
|
@@ -55,6 +54,15 @@ class LocalizedMixin:
|
|
55
54
|
return self.context["locale"]
|
56
55
|
return current_default_locale()
|
57
56
|
|
57
|
+
def format_value(self, value):
|
58
|
+
"""Format the value, gracefully handling exceptions."""
|
59
|
+
try:
|
60
|
+
return super().format_value(value)
|
61
|
+
except Exception as e:
|
62
|
+
# Handle the exception gracefully
|
63
|
+
current_app.logger.error(f"Error formatting value '{value}': {e}")
|
64
|
+
return f"«Error formatting value '{value}'»"
|
65
|
+
|
58
66
|
|
59
67
|
# localized date field
|
60
68
|
class LocalizedDate(LocalizedMixin, FormatDate):
|
@@ -12,11 +12,6 @@ from invenio_i18n import gettext as _
|
|
12
12
|
|
13
13
|
def validate_identifier(value):
|
14
14
|
try:
|
15
|
-
if value["scheme"].lower() == "isbn":
|
16
|
-
canonical_isbn = canonical(value["identifier"])
|
17
|
-
value["identifier"] = mask(canonical_isbn)
|
18
|
-
return value["identifier"]
|
19
|
-
|
20
15
|
original_identifier = (value["identifier"] or '').strip()
|
21
16
|
normalized_identifier = normalize_pid(
|
22
17
|
value["identifier"], value["scheme"].lower()
|
@@ -25,6 +20,15 @@ def validate_identifier(value):
|
|
25
20
|
# the normalize_pid library has problems with isbn - does not raise an exception
|
26
21
|
# but returns an empty string
|
27
22
|
raise ValueError()
|
23
|
+
|
24
|
+
# normalized_pid is changing from 10 length ISBN to 13 length ISBN
|
25
|
+
if value["scheme"].lower() == "isbn":
|
26
|
+
canonical_isbn = canonical(value["identifier"])
|
27
|
+
if original_identifier and not canonical_isbn: # just check in case it returns empty string
|
28
|
+
raise ValueError()
|
29
|
+
value["identifier"] = mask(canonical_isbn)
|
30
|
+
return value
|
31
|
+
|
28
32
|
value["identifier"] = normalized_identifier
|
29
33
|
except:
|
30
34
|
raise ValidationError({
|
@@ -53,13 +53,14 @@ oarepo_runtime/info/views.py,sha256=5ygLgiZilk33OhrnB0h83-MG6K8nsmJFOiJaTBQc43c,
|
|
53
53
|
oarepo_runtime/info/permissions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
54
54
|
oarepo_runtime/info/permissions/debug.py,sha256=2gak5W64g_AAZoX8cCII2di4G_jBo1ZvnU5ceP_u6z4,6722
|
55
55
|
oarepo_runtime/records/__init__.py,sha256=JUf9_o09_6q4vuG43JzhSeTu7c-m_CVDSmgTQ7epYEo,1776
|
56
|
+
oarepo_runtime/records/drafts.py,sha256=8BRmxXcKyVMBQbMMhVScPS_T7lwvR8kGKYQAxaVaD1k,1371
|
56
57
|
oarepo_runtime/records/dumpers/__init__.py,sha256=OmzNhLdMNKibmCksnj9eTX9xPBG30dziiK3j3bAAp3k,233
|
57
58
|
oarepo_runtime/records/dumpers/edtf_interval.py,sha256=8bE3JlaR7b33rxDc7LW9R8jcwNI66Zb07Jee6YUmlrE,1231
|
58
59
|
oarepo_runtime/records/dumpers/multilingual_dumper.py,sha256=PbNFCLsiH4XV3E1v8xga_fzlcEImHy8OXn_UKh_8VBU,1090
|
59
60
|
oarepo_runtime/records/entity_resolvers/__init__.py,sha256=UiiIT54pUu9j7qPAPfqVp4UTnXnppp0c_LtKbFnyt6Y,383
|
60
61
|
oarepo_runtime/records/entity_resolvers/proxies.py,sha256=R92Cil_sTgX-sHJtdNv82yd-F3SUfsGSNCHdwI9Zfq8,1516
|
61
62
|
oarepo_runtime/records/mappings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
62
|
-
oarepo_runtime/records/mappings/rdm_parent_mapping.json,sha256=
|
63
|
+
oarepo_runtime/records/mappings/rdm_parent_mapping.json,sha256=ykgVr-navpy-HlhUN78sZ1ZpcAaduzZ0ESpphLK4b5E,14233
|
63
64
|
oarepo_runtime/records/owners/__init__.py,sha256=R4hudCBqLRRzgCnkEjXIL7hSp068z-s6YOwYSkWyuaw,93
|
64
65
|
oarepo_runtime/records/owners/registry.py,sha256=fYgBuW5nBKn6pyz2OBgfNlynk64_yhQ9J7FzPk8QU1U,795
|
65
66
|
oarepo_runtime/records/relations/__init__.py,sha256=Zn7JeQrd5f1doWl5IpbNSpO8m8hm1m-oljAW-7WHn-k,477
|
@@ -82,15 +83,16 @@ oarepo_runtime/resources/file_resource.py,sha256=Ta3bFce7l0xwqkkOMOEu9mxbB8BbKj5
|
|
82
83
|
oarepo_runtime/resources/json_serializer.py,sha256=82_-xQEtxKaPakv8R1oBAFbGnxskF_Ve4tcfcy4PetI,963
|
83
84
|
oarepo_runtime/resources/localized_ui_json_serializer.py,sha256=3V9cJaG_e1PMXKVX_wKfBp1LmbeForwHyBNYdyha4uQ,1878
|
84
85
|
oarepo_runtime/resources/resource.py,sha256=GK5yGnJIjH60wGqqDoOfwMQQFQDLZhJpU4zBJOmABI8,2063
|
85
|
-
oarepo_runtime/resources/responses.py,sha256=
|
86
|
+
oarepo_runtime/resources/responses.py,sha256=Pj-K_r-QO9B2n9STcfqsrBQu1e3iYhdEBFSVTeWR7cM,738
|
86
87
|
oarepo_runtime/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
87
88
|
oarepo_runtime/services/components.py,sha256=0aqmuNbGCQhfOI22f6mM2DxuKSTqstGOGyisOiqw9KE,15481
|
88
89
|
oarepo_runtime/services/generators.py,sha256=j87HitHA_w2awsz0C5IAAJ0qjg9JMtvdO3dvh6FQyfg,250
|
89
90
|
oarepo_runtime/services/results.py,sha256=Ap2mUJHl3V4BSduTrBWPuco0inQVq0QsuCbVhez48uY,5705
|
90
91
|
oarepo_runtime/services/search.py,sha256=t0WEe2VrbCzZ06-Jgz7C9-pc9y27BqAgTEXldEHskfk,9409
|
91
92
|
oarepo_runtime/services/service.py,sha256=TI2ulEVlSR7HZnfPYltLl8Vf4O9fhJ7rHaV6G4HWbrc,1893
|
92
|
-
oarepo_runtime/services/config/__init__.py,sha256=
|
93
|
-
oarepo_runtime/services/config/
|
93
|
+
oarepo_runtime/services/config/__init__.py,sha256=aRxCBLN9pqCgdYlF-KJYtDzt2mwJ66npdceOAZkMfa0,888
|
94
|
+
oarepo_runtime/services/config/draft_link.py,sha256=Hq541t33F3lEZo6XTexzdxneKJOmLBLujFdyT1w1TbE,698
|
95
|
+
oarepo_runtime/services/config/link_conditions.py,sha256=5hDEtCaQt1tzjb9gGdeimsmKNoWWPicIeYKfI8Fg8Qw,3866
|
94
96
|
oarepo_runtime/services/config/permissions_presets.py,sha256=b1wm3JjL8KgkaH7VMkNfdMk5fXtf3X87rB7gkvaNxns,7369
|
95
97
|
oarepo_runtime/services/config/service.py,sha256=s-dVbGkLICpsce6jgu7b5kzYFz9opWjSQFDBgbIhKio,4002
|
96
98
|
oarepo_runtime/services/custom_fields/__init__.py,sha256=_gqMcA_I3rdEZcBtCuDjO4wdVCqFML5NzaccuPx5a3o,2565
|
@@ -133,8 +135,8 @@ oarepo_runtime/services/schema/oneofschema.py,sha256=GnWH4Or_G5M0NgSmCoqMI6PBrJg
|
|
133
135
|
oarepo_runtime/services/schema/polymorphic.py,sha256=bAbUoTIeDBiJPYPhpLEKKZekEdkHlpqkmNxk1hN3PDw,564
|
134
136
|
oarepo_runtime/services/schema/rdm.py,sha256=dBy1KCJ_XYAN_cffoRqLfQVEdZOKwmSpqGdEP4OL64k,1280
|
135
137
|
oarepo_runtime/services/schema/rdm_ui.py,sha256=KBTPAv4NkTNuhxIbOGzdBUXkwqKb-2q5EjWH2eTzc84,3430
|
136
|
-
oarepo_runtime/services/schema/ui.py,sha256=
|
137
|
-
oarepo_runtime/services/schema/validation.py,sha256=
|
138
|
+
oarepo_runtime/services/schema/ui.py,sha256=ae75YON8yNGxblywCgqX2OS9ACXHGzcN_adlLKIRUYk,7937
|
139
|
+
oarepo_runtime/services/schema/validation.py,sha256=aRfeR-2D1XXYqI3_U5FHoFvJrYjZlpM8nB35-M_u3Qs,2300
|
138
140
|
oarepo_runtime/translations/default_translations.py,sha256=060GBlA1ghWxfeumo6NqxCCZDb-6OezOuF6pr-_GEOQ,104
|
139
141
|
oarepo_runtime/translations/messages.pot,sha256=wr1vDKjsngqS9e5zQmSAsF3qUAtpQ41SUXwzEKRCnWw,2406
|
140
142
|
oarepo_runtime/translations/cs/LC_MESSAGES/messages.mo,sha256=mhVcQhLPW0QG_l4sYDiaiKc67oEVWVVYlwBxeQyDZdY,1044
|
@@ -148,9 +150,9 @@ tests/marshmallow_to_json/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
148
150
|
tests/marshmallow_to_json/test_datacite_ui_schema.py,sha256=82iLj8nW45lZOUewpWbLX3mpSkpa9lxo-vK-Qtv_1bU,48552
|
149
151
|
tests/marshmallow_to_json/test_simple_schema.py,sha256=izZN9p0v6kovtSZ6AdxBYmK_c6ZOti2_z_wPT_zXIr0,1500
|
150
152
|
tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
151
|
-
oarepo_runtime-1.5.
|
152
|
-
oarepo_runtime-1.5.
|
153
|
-
oarepo_runtime-1.5.
|
154
|
-
oarepo_runtime-1.5.
|
155
|
-
oarepo_runtime-1.5.
|
156
|
-
oarepo_runtime-1.5.
|
153
|
+
oarepo_runtime-1.5.129.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
|
154
|
+
oarepo_runtime-1.5.129.dist-info/METADATA,sha256=MEE87EgTSva-yYSr22h56-RtZxqaM9r1VQG0HEtOleg,4721
|
155
|
+
oarepo_runtime-1.5.129.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
156
|
+
oarepo_runtime-1.5.129.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
|
157
|
+
oarepo_runtime-1.5.129.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
|
158
|
+
oarepo_runtime-1.5.129.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|