oarepo-runtime 1.5.103__py3-none-any.whl → 1.5.104__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,13 +1,35 @@
1
1
  import marshmallow as ma
2
2
 
3
3
  from marshmallow import fields as ma_fields
4
+ from marshmallow import pre_load
4
5
  from marshmallow_utils.fields.nestedattr import NestedAttribute
5
6
  from invenio_rdm_records.services.schemas.versions import VersionsSchema
6
7
  from invenio_rdm_records.services.schemas.tombstone import DeletionStatusSchema
7
8
  from invenio_rdm_records.services.schemas.access import AccessSchema
8
-
9
+ from invenio_vocabularies.contrib.awards.schema import AwardRelationSchema
10
+ from invenio_vocabularies.contrib.funders.schema import FunderRelationSchema
11
+ from invenio_i18n.selectors import get_locale
9
12
 
10
13
  class RDMRecordMixin(ma.Schema):
11
14
 
12
15
  versions = NestedAttribute(VersionsSchema, dump_only=True)
13
- deletion_status = ma_fields.Nested(DeletionStatusSchema, dump_only=True)
16
+ deletion_status = ma_fields.Nested(DeletionStatusSchema, dump_only=True)
17
+
18
+
19
+ class MultilingualAwardSchema(AwardRelationSchema):
20
+ class Meta:
21
+ unknown = ma.RAISE
22
+
23
+ @pre_load()
24
+ def convert_to_multilingual(self, data, many, **kwargs):
25
+ if "title" in data:
26
+ lang = get_locale()
27
+ data["title"] = {lang: data["title"]}
28
+ return data
29
+
30
+
31
+ class FundingSchema(ma.Schema):
32
+ """Funding schema."""
33
+
34
+ funder = fields.Nested(FunderRelationSchema, required=True)
35
+ award = fields.Nested(MultilingualAwardSchema)
@@ -0,0 +1,113 @@
1
+ import marshmallow as ma
2
+ from oarepo_runtime.services.schema.marshmallow import DictOnlySchema
3
+
4
+ class RDMIdentifierWithSchemaUISchema(ma.Schema):
5
+ scheme = ma.fields.String(
6
+ required=True,
7
+ )
8
+ identifier = ma.fields.String(required=True)
9
+
10
+ class RDMAwardIdentifierUISchema(ma.Schema):
11
+ identifier = ma.fields.String()
12
+
13
+ class RDMAwardSubjectUISchema(ma.Schema):
14
+ _id = ma.fields.String(data_key="id")
15
+
16
+ subject = ma.fields.String()
17
+
18
+ class RDMAwardOrganizationUISchema(ma.Schema):
19
+ schema = ma.fields.String()
20
+
21
+ _id = ma.fields.String(data_key="id")
22
+
23
+ organization = ma.fields.String()
24
+
25
+ class RDMFunderVocabularyUISchema(DictOnlySchema):
26
+ class Meta:
27
+ unknown = ma.INCLUDE
28
+
29
+ _id = ma.fields.String(data_key="id", attribute="id")
30
+
31
+ _version = ma.fields.String(data_key="@v", attribute="@v")
32
+
33
+ name = VocabularyI18nStrUIField()
34
+
35
+ identifier = ma.fields.Nested(RDMIdentifierWithSchemaUISchema())
36
+
37
+
38
+ class RDMRoleVocabularyUISchema(DictOnlySchema):
39
+ class Meta:
40
+ unknown = ma.INCLUDE
41
+
42
+ _id = String(data_key="id", attribute="id")
43
+
44
+ _version = String(data_key="@v", attribute="@v")
45
+
46
+ class RDMAwardVocabularyUISchema(DictOnlySchema):
47
+ class Meta:
48
+ unknown = ma.INCLUDE
49
+
50
+ _id = String(data_key="id", attribute="id")
51
+
52
+ _version = String(data_key="@v", attribute="@v")
53
+
54
+ title = VocabularyI18nStrUIField()
55
+
56
+ number = ma.fields.String()
57
+
58
+ identifier = ma.fields.List(ma.fields.Nested(RDMAwardIdentifierUISchema()))
59
+
60
+ acronym = ma.fields.String()
61
+
62
+ program = ma.fields.String()
63
+
64
+ subjects = ma.fields.List(ma.fields.Nested(RDMAwardSubjectUISchema()))
65
+
66
+ organizations = ma.fields.List(ma.fields.Nested(RDMAwardOrganizationUISchema()))
67
+
68
+
69
+ class RDMFundersUISchema(ma.Schema):
70
+ """Funding ui schema."""
71
+ class Meta:
72
+ unknown = ma.RAISE
73
+
74
+ funder = ma_fields.Nested(lambda: RDMFunderVocabularyUISchema())
75
+
76
+ award = ma_fields.Nested(lambda: RDMAwardVocabularyUISchema())
77
+
78
+
79
+ class RDMPersonOrOrganizationUISchema(ma.Schema):
80
+ class Meta:
81
+ unknown = ma.INCLUDE
82
+
83
+ name = ma.fields.String()
84
+
85
+ type = ma.fields.String()
86
+
87
+ given_name = ma.fields.String()
88
+
89
+ family_name = ma.fields.String()
90
+
91
+ identifiers = ma.fields.List(ma.fields.Nested(RDMIdentifierWithSchemaUISchema()))
92
+
93
+
94
+ class RDMAffiliationVocabularyUISchema(DictOnlySchema):
95
+ class Meta:
96
+ unknown = ma.INCLUDE
97
+
98
+ _id = ma.fields.String(data_key="id", attribute="id")
99
+
100
+ _version = ma.fields.String(data_key="@v", attribute="@v")
101
+
102
+ name = VocabularyI18nStrUIField()
103
+
104
+ class RDMCreatorsUISchema(ma.Schema):
105
+ """Funding ui schema."""
106
+ class Meta:
107
+ unknown = ma.RAISE
108
+
109
+ role = ma.fields.Nested(lambda: RDMRoleVocabularyUISchema())
110
+
111
+ affiliations = ma.fields.List(ma_fields.Nested(lambda: RDMAffiliationVocabularyUISchema()))
112
+
113
+ person_or_org = ma_fields.Nested(RDMPersonOrOrganizationUISchema())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: oarepo-runtime
3
- Version: 1.5.103
3
+ Version: 1.5.104
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -126,7 +126,8 @@ oarepo_runtime/services/schema/marshmallow.py,sha256=iAMMH5MlYs59qetXAHOROvERNSc
126
126
  oarepo_runtime/services/schema/marshmallow_to_json_schema.py,sha256=VYLnVWHOoaxWCD_gqJO8-8u1SbaPEFBjDZ5HGgGr0Ow,2027
127
127
  oarepo_runtime/services/schema/oneofschema.py,sha256=GnWH4Or_G5M0NgSmCoqMI6PBrJg5AC9RHrcB5QDKRq0,6661
128
128
  oarepo_runtime/services/schema/polymorphic.py,sha256=bAbUoTIeDBiJPYPhpLEKKZekEdkHlpqkmNxk1hN3PDw,564
129
- oarepo_runtime/services/schema/rdm.py,sha256=4gi44LIMWS9kWcZfEoHaJSq585qfZfMuUYM5IvL1nQo,531
129
+ oarepo_runtime/services/schema/rdm.py,sha256=ckcv_imYCG56_qwxVDZCt04D0tvI8I--NLHQU6iTwVc,1242
130
+ oarepo_runtime/services/schema/rdm_ui.py,sha256=rAaEfASbERy_LM7gdHMBfpG2sRQThyf1oK6vtr9EfMs,2910
130
131
  oarepo_runtime/services/schema/ui.py,sha256=hHbj1S-DW1WqgYX31f6UjarY4wrE-qFLpH3oUhvGLyE,6192
131
132
  oarepo_runtime/services/schema/validation.py,sha256=VFOKSxQLHwFb7bW8BJAFXWe_iTAZFOfqOnb2Ko_Yxxc,2085
132
133
  oarepo_runtime/translations/default_translations.py,sha256=060GBlA1ghWxfeumo6NqxCCZDb-6OezOuF6pr-_GEOQ,104
@@ -142,9 +143,9 @@ tests/marshmallow_to_json/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
142
143
  tests/marshmallow_to_json/test_datacite_ui_schema.py,sha256=82iLj8nW45lZOUewpWbLX3mpSkpa9lxo-vK-Qtv_1bU,48552
143
144
  tests/marshmallow_to_json/test_simple_schema.py,sha256=izZN9p0v6kovtSZ6AdxBYmK_c6ZOti2_z_wPT_zXIr0,1500
144
145
  tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
145
- oarepo_runtime-1.5.103.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
146
- oarepo_runtime-1.5.103.dist-info/METADATA,sha256=bLIBuMCjXm85bclvhOvWFWBfpCglssd-Xt4AiPUB6rI,4721
147
- oarepo_runtime-1.5.103.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
148
- oarepo_runtime-1.5.103.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
149
- oarepo_runtime-1.5.103.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
150
- oarepo_runtime-1.5.103.dist-info/RECORD,,
146
+ oarepo_runtime-1.5.104.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
147
+ oarepo_runtime-1.5.104.dist-info/METADATA,sha256=fcQq0-4iGSSdX-gylDoUeAQ4kNogetyenOB3S6fVBUQ,4721
148
+ oarepo_runtime-1.5.104.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
149
+ oarepo_runtime-1.5.104.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
150
+ oarepo_runtime-1.5.104.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
151
+ oarepo_runtime-1.5.104.dist-info/RECORD,,