oarepo-runtime 1.5.54__py3-none-any.whl → 1.5.55__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.
@@ -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
- for cf in cf_registry.lookup(type(record)):
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
- setattr(record, cf.attr_name, data.get(cf.key, {}))
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.5.54
3
+ Version: 1.5.55
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -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=qvzdzE4fdRNDm5Eei7WYssKNroQp9YnFP1HCOl1-Ijw,2942
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.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,,
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,,