oarepo-runtime 1.5.52__py3-none-any.whl → 1.5.54__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/info/views.py +1 -1
- oarepo_runtime/services/components.py +29 -0
- oarepo_runtime/services/custom_fields/__init__.py +10 -1
- {oarepo_runtime-1.5.52.dist-info → oarepo_runtime-1.5.54.dist-info}/METADATA +1 -1
- {oarepo_runtime-1.5.52.dist-info → oarepo_runtime-1.5.54.dist-info}/RECORD +9 -9
- {oarepo_runtime-1.5.52.dist-info → oarepo_runtime-1.5.54.dist-info}/LICENSE +0 -0
- {oarepo_runtime-1.5.52.dist-info → oarepo_runtime-1.5.54.dist-info}/WHEEL +0 -0
- {oarepo_runtime-1.5.52.dist-info → oarepo_runtime-1.5.54.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-1.5.52.dist-info → oarepo_runtime-1.5.54.dist-info}/top_level.txt +0 -0
oarepo_runtime/info/views.py
CHANGED
@@ -197,7 +197,7 @@ class InfoResource(Resource):
|
|
197
197
|
return ret
|
198
198
|
|
199
199
|
def call_components(self, method_name, **kwargs):
|
200
|
-
for component in self.
|
200
|
+
for component in self.components:
|
201
201
|
if hasattr(component, method_name):
|
202
202
|
getattr(component, method_name)(**kwargs)
|
203
203
|
|
@@ -1,5 +1,11 @@
|
|
1
|
+
import inspect
|
2
|
+
from collections import defaultdict
|
3
|
+
from typing import Type
|
4
|
+
|
1
5
|
from invenio_accounts.models import User
|
6
|
+
from invenio_records import Record
|
2
7
|
|
8
|
+
from oarepo_runtime.services.custom_fields import CustomFieldsMixin
|
3
9
|
from oarepo_runtime.services.generators import RecordOwners
|
4
10
|
|
5
11
|
try:
|
@@ -51,3 +57,26 @@ class DateIssuedComponent(ServiceComponent):
|
|
51
57
|
"""Create a new record."""
|
52
58
|
if "dateIssued" not in record["metadata"]:
|
53
59
|
record["metadata"]["dateIssued"] = datetime.today().strftime("%Y-%m-%d")
|
60
|
+
|
61
|
+
class CFRegistry:
|
62
|
+
def __init__(self):
|
63
|
+
self.custom_field_names = defaultdict(list)
|
64
|
+
|
65
|
+
def lookup(self, record_type: Type[Record]):
|
66
|
+
if record_type not in self.custom_field_names:
|
67
|
+
for fld in inspect.getmembers(record_type, lambda x: isinstance(x, CustomFieldsMixin)):
|
68
|
+
self.custom_field_names[record_type].append(fld[1])
|
69
|
+
return self.custom_field_names[record_type]
|
70
|
+
|
71
|
+
cf_registry = CFRegistry()
|
72
|
+
|
73
|
+
class CustomFieldsComponent(ServiceComponent):
|
74
|
+
def create(self, identity, data=None, record=None, **kwargs):
|
75
|
+
"""Create a new record."""
|
76
|
+
for cf in cf_registry.lookup(type(record)):
|
77
|
+
setattr(record, cf.attr_name, data.get(cf.key, {}))
|
78
|
+
|
79
|
+
def update(self, identity, data=None, record=None, **kwargs):
|
80
|
+
"""Update a record."""
|
81
|
+
for cf in cf_registry.lookup(type(record)):
|
82
|
+
setattr(record, cf.attr_name, data.get(cf.key, {}))
|
@@ -43,7 +43,16 @@ class CustomFields(CustomFieldsMixin, DictField):
|
|
43
43
|
|
44
44
|
|
45
45
|
class InlinedCustomFields(CustomFieldsMixin, SystemField):
|
46
|
-
|
46
|
+
|
47
|
+
def __get__(self, record, owner=None):
|
48
|
+
"""Getting the attribute value."""
|
49
|
+
if record is None:
|
50
|
+
return self
|
51
|
+
return self.get_dictkey(record)
|
52
|
+
|
53
|
+
def __set__(self, record, value):
|
54
|
+
"""Setting a new value."""
|
55
|
+
self.set_dictkey(record, value)
|
47
56
|
|
48
57
|
|
49
58
|
class InlinedCustomFieldsSchemaMixin:
|
@@ -41,7 +41,7 @@ oarepo_runtime/datastreams/writers/validation_errors.py,sha256=wOCXdniR6so_4Expd
|
|
41
41
|
oarepo_runtime/datastreams/writers/yaml.py,sha256=XchUJHQ58E2Mfgs8elImXbL38jFtI8Hfoye6yaR0gKI,1482
|
42
42
|
oarepo_runtime/i18n/__init__.py,sha256=h0knW_HwiyIt5TBHfdGqN7_BBYfpz1Fw6zhVy0C28fM,111
|
43
43
|
oarepo_runtime/info/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
44
|
-
oarepo_runtime/info/views.py,sha256=
|
44
|
+
oarepo_runtime/info/views.py,sha256=bH0FWS3SHpUmACeXOVwTIcSHa8qQvo19jMYEAEYhTu8,11110
|
45
45
|
oarepo_runtime/records/__init__.py,sha256=3vzRsAPxl4d5QOnGyls-vUg4E6PunmR4ACObtacMAIQ,1038
|
46
46
|
oarepo_runtime/records/dumpers/__init__.py,sha256=OmzNhLdMNKibmCksnj9eTX9xPBG30dziiK3j3bAAp3k,233
|
47
47
|
oarepo_runtime/records/dumpers/edtf_interval.py,sha256=YCShZAoqBQYaxVilEVotS-jXZsxxoXO67yu2urhkaMA,1198
|
@@ -68,14 +68,14 @@ 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=qvzdzE4fdRNDm5Eei7WYssKNroQp9YnFP1HCOl1-Ijw,2942
|
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
|
75
75
|
oarepo_runtime/services/config/__init__.py,sha256=dtlD84pJ6xI77UF22IPrCOt7tHD3g5DAEDApUdjDVFE,406
|
76
76
|
oarepo_runtime/services/config/permissions_presets.py,sha256=zApeA-2DYAlD--SzVz3vq_OFjq48Ko0pe08e4o2vxr4,6114
|
77
77
|
oarepo_runtime/services/config/service.py,sha256=s-dVbGkLICpsce6jgu7b5kzYFz9opWjSQFDBgbIhKio,4002
|
78
|
-
oarepo_runtime/services/custom_fields/__init__.py,sha256=
|
78
|
+
oarepo_runtime/services/custom_fields/__init__.py,sha256=_gqMcA_I3rdEZcBtCuDjO4wdVCqFML5NzaccuPx5a3o,2565
|
79
79
|
oarepo_runtime/services/custom_fields/mappings.py,sha256=tg9CAdxGOkd_n6RB5Z2_wSwo_A0wqEey8RMcZ79AHo0,6906
|
80
80
|
oarepo_runtime/services/expansions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
81
81
|
oarepo_runtime/services/expansions/expandable_fields.py,sha256=7DWKFL6ml8J7zGI6wm9LO7Xd6R0LSylsuq4lyRumNHQ,745
|
@@ -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.54.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
|
123
|
+
oarepo_runtime-1.5.54.dist-info/METADATA,sha256=LPFQp3spmVqEdbZ0A9VyGuftVZEqX7D4CqSRudES5D4,4720
|
124
|
+
oarepo_runtime-1.5.54.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
125
|
+
oarepo_runtime-1.5.54.dist-info/entry_points.txt,sha256=QrlXAKuPDVBinaSh_v3yO9_Nb9ZNmJCJ0VFcCW-z0Jg,327
|
126
|
+
oarepo_runtime-1.5.54.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
|
127
|
+
oarepo_runtime-1.5.54.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|