oarepo-runtime 1.5.103__py3-none-any.whl → 1.5.105__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,114 @@
1
+ import marshmallow as ma
2
+ from oarepo_runtime.services.schema.marshmallow import DictOnlySchema
3
+ from oarepo_vocabularies.services.ui_schema import VocabularyI18nStrUIField
4
+
5
+ class RDMIdentifierWithSchemaUISchema(ma.Schema):
6
+ scheme = ma.fields.String(
7
+ required=True,
8
+ )
9
+ identifier = ma.fields.String(required=True)
10
+
11
+ class RDMAwardIdentifierUISchema(ma.Schema):
12
+ identifier = ma.fields.String()
13
+
14
+ class RDMAwardSubjectUISchema(ma.Schema):
15
+ _id = ma.fields.String(data_key="id")
16
+
17
+ subject = ma.fields.String()
18
+
19
+ class RDMAwardOrganizationUISchema(ma.Schema):
20
+ schema = ma.fields.String()
21
+
22
+ _id = ma.fields.String(data_key="id")
23
+
24
+ organization = ma.fields.String()
25
+
26
+ class RDMFunderVocabularyUISchema(DictOnlySchema):
27
+ class Meta:
28
+ unknown = ma.INCLUDE
29
+
30
+ _id = ma.fields.String(data_key="id", attribute="id")
31
+
32
+ _version = ma.fields.String(data_key="@v", attribute="@v")
33
+
34
+ name = VocabularyI18nStrUIField()
35
+
36
+ identifier = ma.fields.Nested(RDMIdentifierWithSchemaUISchema())
37
+
38
+
39
+ class RDMRoleVocabularyUISchema(DictOnlySchema):
40
+ class Meta:
41
+ unknown = ma.INCLUDE
42
+
43
+ _id = ma.fields.String(data_key="id", attribute="id")
44
+
45
+ _version = ma.fields.String(data_key="@v", attribute="@v")
46
+
47
+ class RDMAwardVocabularyUISchema(DictOnlySchema):
48
+ class Meta:
49
+ unknown = ma.INCLUDE
50
+
51
+ _id = ma.fields.String(data_key="id", attribute="id")
52
+
53
+ _version = ma.fields.String(data_key="@v", attribute="@v")
54
+
55
+ title = VocabularyI18nStrUIField()
56
+
57
+ number = ma.fields.String()
58
+
59
+ identifier = ma.fields.List(ma.fields.Nested(RDMAwardIdentifierUISchema()))
60
+
61
+ acronym = ma.fields.String()
62
+
63
+ program = ma.fields.String()
64
+
65
+ subjects = ma.fields.List(ma.fields.Nested(RDMAwardSubjectUISchema()))
66
+
67
+ organizations = ma.fields.List(ma.fields.Nested(RDMAwardOrganizationUISchema()))
68
+
69
+
70
+ class RDMFundersUISchema(ma.Schema):
71
+ """Funding ui schema."""
72
+ class Meta:
73
+ unknown = ma.RAISE
74
+
75
+ funder = ma.fields.Nested(lambda: RDMFunderVocabularyUISchema())
76
+
77
+ award = ma.fields.Nested(lambda: RDMAwardVocabularyUISchema())
78
+
79
+
80
+ class RDMPersonOrOrganizationUISchema(ma.Schema):
81
+ class Meta:
82
+ unknown = ma.INCLUDE
83
+
84
+ name = ma.fields.String()
85
+
86
+ type = ma.fields.String()
87
+
88
+ given_name = ma.fields.String()
89
+
90
+ family_name = ma.fields.String()
91
+
92
+ identifiers = ma.fields.List(ma.fields.Nested(RDMIdentifierWithSchemaUISchema()))
93
+
94
+
95
+ class RDMAffiliationVocabularyUISchema(DictOnlySchema):
96
+ class Meta:
97
+ unknown = ma.INCLUDE
98
+
99
+ _id = ma.fields.String(data_key="id", attribute="id")
100
+
101
+ _version = ma.fields.String(data_key="@v", attribute="@v")
102
+
103
+ name = VocabularyI18nStrUIField()
104
+
105
+ class RDMCreatorsUISchema(ma.Schema):
106
+ """Funding ui schema."""
107
+ class Meta:
108
+ unknown = ma.RAISE
109
+
110
+ role = ma.fields.Nested(lambda: RDMRoleVocabularyUISchema())
111
+
112
+ affiliations = ma.fields.List(ma.fields.Nested(lambda: RDMAffiliationVocabularyUISchema()))
113
+
114
+ 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.105
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=Vs9kOaQ0ZPPZpSqEXlu0vQrt-458Aci9u9T4YONSJLs,3026
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.105.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
147
+ oarepo_runtime-1.5.105.dist-info/METADATA,sha256=81-KfaOYNSYy_lY27QN7I2OahhNmt9osw3WPKfv-s3o,4721
148
+ oarepo_runtime-1.5.105.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
149
+ oarepo_runtime-1.5.105.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
150
+ oarepo_runtime-1.5.105.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
151
+ oarepo_runtime-1.5.105.dist-info/RECORD,,