oarepo-runtime 1.5.54__py3-none-any.whl → 1.5.55__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- oarepo_runtime/services/components.py +12 -4
- {oarepo_runtime-1.5.54.dist-info → oarepo_runtime-1.5.55.dist-info}/METADATA +1 -1
- {oarepo_runtime-1.5.54.dist-info → oarepo_runtime-1.5.55.dist-info}/RECORD +7 -7
- {oarepo_runtime-1.5.54.dist-info → oarepo_runtime-1.5.55.dist-info}/LICENSE +0 -0
- {oarepo_runtime-1.5.54.dist-info → oarepo_runtime-1.5.55.dist-info}/WHEEL +0 -0
- {oarepo_runtime-1.5.54.dist-info → oarepo_runtime-1.5.55.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-1.5.54.dist-info → oarepo_runtime-1.5.55.dist-info}/top_level.txt +0 -0
@@ -2,10 +2,11 @@ import inspect
|
|
2
2
|
from collections import defaultdict
|
3
3
|
from typing import Type
|
4
4
|
|
5
|
+
from flask import current_app
|
5
6
|
from invenio_accounts.models import User
|
6
7
|
from invenio_records import Record
|
7
8
|
|
8
|
-
from oarepo_runtime.services.custom_fields import CustomFieldsMixin
|
9
|
+
from oarepo_runtime.services.custom_fields import CustomFieldsMixin, CustomFields, InlinedCustomFields
|
9
10
|
from oarepo_runtime.services.generators import RecordOwners
|
10
11
|
|
11
12
|
try:
|
@@ -73,10 +74,17 @@ cf_registry = CFRegistry()
|
|
73
74
|
class CustomFieldsComponent(ServiceComponent):
|
74
75
|
def create(self, identity, data=None, record=None, **kwargs):
|
75
76
|
"""Create a new record."""
|
76
|
-
|
77
|
-
setattr(record, cf.attr_name, data.get(cf.key, {}))
|
77
|
+
self._set_cf_to_record(record, data)
|
78
78
|
|
79
79
|
def update(self, identity, data=None, record=None, **kwargs):
|
80
80
|
"""Update a record."""
|
81
|
+
self._set_cf_to_record(record, data)
|
82
|
+
|
83
|
+
def _set_cf_to_record(self, record, data):
|
81
84
|
for cf in cf_registry.lookup(type(record)):
|
82
|
-
|
85
|
+
if isinstance(cf, CustomFields):
|
86
|
+
setattr(record, cf.attr_name, data.get(cf.key, {}))
|
87
|
+
elif isinstance(cf, InlinedCustomFields):
|
88
|
+
config = current_app.config.get(cf.config_key, {})
|
89
|
+
for c in config:
|
90
|
+
record[c.name] =data.get(c.name)
|
@@ -68,7 +68,7 @@ oarepo_runtime/resources/__init__.py,sha256=v8BGrOTu_FjKzd0eozV7Q4GoGxyfybsL2cI-
|
|
68
68
|
oarepo_runtime/resources/file_resource.py,sha256=Ta3bFce7l0xwqkkOMOEu9mxbB8BbKj5HUHRHmidhnl8,414
|
69
69
|
oarepo_runtime/resources/localized_ui_json_serializer.py,sha256=3V9cJaG_e1PMXKVX_wKfBp1LmbeForwHyBNYdyha4uQ,1878
|
70
70
|
oarepo_runtime/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
71
|
-
oarepo_runtime/services/components.py,sha256=
|
71
|
+
oarepo_runtime/services/components.py,sha256=zaZroTqzV5fz8yVAtRFLbbkTT9iD_dx9jFYANm3JIfI,3285
|
72
72
|
oarepo_runtime/services/generators.py,sha256=j87HitHA_w2awsz0C5IAAJ0qjg9JMtvdO3dvh6FQyfg,250
|
73
73
|
oarepo_runtime/services/results.py,sha256=gPmQ7DzX4da5zuvqQE7u-AUn_Yvz-YHt8W8DaxPbQ-M,2706
|
74
74
|
oarepo_runtime/services/search.py,sha256=9xGTN5Yg6eTdptQ9qjO_umbacf9ooMuHYGXWYfla4-M,6227
|
@@ -119,9 +119,9 @@ oarepo_runtime/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
|
|
119
119
|
oarepo_runtime/utils/functools.py,sha256=gKS9YZtlIYcDvdNA9cmYO00yjiXBYV1jg8VpcRUyQyg,1324
|
120
120
|
oarepo_runtime/utils/path.py,sha256=V1NVyk3m12_YLbj7QHYvUpE1wScO78bYsX1LOLeXDkI,3108
|
121
121
|
tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
122
|
-
oarepo_runtime-1.5.
|
123
|
-
oarepo_runtime-1.5.
|
124
|
-
oarepo_runtime-1.5.
|
125
|
-
oarepo_runtime-1.5.
|
126
|
-
oarepo_runtime-1.5.
|
127
|
-
oarepo_runtime-1.5.
|
122
|
+
oarepo_runtime-1.5.55.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
|
123
|
+
oarepo_runtime-1.5.55.dist-info/METADATA,sha256=QkP7AUW4cdDHjbJ8UwGLkmUlp23l_q57oFfIr9B4FB0,4720
|
124
|
+
oarepo_runtime-1.5.55.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
125
|
+
oarepo_runtime-1.5.55.dist-info/entry_points.txt,sha256=QrlXAKuPDVBinaSh_v3yO9_Nb9ZNmJCJ0VFcCW-z0Jg,327
|
126
|
+
oarepo_runtime-1.5.55.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
|
127
|
+
oarepo_runtime-1.5.55.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|