oarepo-runtime 1.5.122__py3-none-any.whl → 1.5.124__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.
@@ -39,7 +39,7 @@ class OaiHarvesterPermissionPolicy(RecordPermissionPolicy):
39
39
  can_draft_commit_files = [SystemProcess()]
40
40
  can_draft_read_files = [SystemProcess()]
41
41
  can_draft_update_files = [SystemProcess()]
42
-
42
+ can_draft_delete_files = [SystemProcess()]
43
43
 
44
44
 
45
45
  class ReadOnlyPermissionPolicy(RecordPermissionPolicy):
@@ -76,6 +76,7 @@ class ReadOnlyPermissionPolicy(RecordPermissionPolicy):
76
76
  can_draft_commit_files = [SystemProcess()]
77
77
  can_draft_read_files = [SystemProcess()]
78
78
  can_draft_update_files = [SystemProcess()]
79
+ can_draft_delete_files = [SystemProcess()]
79
80
 
80
81
  can_add_community = [SystemProcess()]
81
82
  can_remove_community = [SystemProcess()]
@@ -85,7 +86,6 @@ class ReadOnlyPermissionPolicy(RecordPermissionPolicy):
85
86
  can_lift_embargo = [SystemProcess()]
86
87
 
87
88
 
88
-
89
89
  class EveryonePermissionPolicy(RecordPermissionPolicy):
90
90
  """record policy for read only repository"""
91
91
 
@@ -120,6 +120,7 @@ class EveryonePermissionPolicy(RecordPermissionPolicy):
120
120
  can_draft_commit_files = [SystemProcess(), AnyUser()]
121
121
  can_draft_read_files = [SystemProcess(), AnyUser()]
122
122
  can_draft_update_files = [SystemProcess(), AnyUser()]
123
+ can_draft_delete_files = [SystemProcess(), AnyUser()]
123
124
 
124
125
  can_add_community = [SystemProcess(), AnyUser()]
125
126
  can_remove_community = [SystemProcess(), AnyUser()]
@@ -148,6 +149,7 @@ class AuthenticatedPermissionPolicy(RecordPermissionPolicy):
148
149
  can_update_files = [SystemProcess(), AuthenticatedUser()]
149
150
  can_list_files = [SystemProcess(), AuthenticatedUser()]
150
151
  can_manage_files = [SystemProcess(), AuthenticatedUser()]
152
+ can_delete_files = [SystemProcess(), AuthenticatedUser()]
151
153
 
152
154
  can_edit = [SystemProcess(), AuthenticatedUser()]
153
155
  can_new_version = [SystemProcess(), AuthenticatedUser()]
@@ -163,10 +165,10 @@ class AuthenticatedPermissionPolicy(RecordPermissionPolicy):
163
165
  can_draft_commit_files = [SystemProcess(), AuthenticatedUser()]
164
166
  can_draft_read_files = [SystemProcess(), AuthenticatedUser()]
165
167
  can_draft_update_files = [SystemProcess(), AuthenticatedUser()]
168
+ can_draft_delete_files = [SystemProcess(), AuthenticatedUser()]
166
169
 
167
170
  can_add_community = [SystemProcess(), AuthenticatedUser()]
168
171
  can_remove_community = [SystemProcess(), AuthenticatedUser()]
169
172
 
170
- can_delete_files = [SystemProcess(), AuthenticatedUser()]
171
173
  can_manage_record_access = [SystemProcess(), AuthenticatedUser()]
172
174
  can_lift_embargo = [SystemProcess(), AuthenticatedUser()]
@@ -2,6 +2,9 @@ import datetime
2
2
  import re
3
3
 
4
4
  import marshmallow as ma
5
+ from marshmallow.fields import Dict, Nested
6
+ from marshmallow_utils.fields import SanitizedUnicode
7
+ from invenio_rdm_records.services.schemas.pids import PIDSchema
5
8
  from babel.dates import format_date
6
9
  from babel_edtf import format_edtf
7
10
  from flask import current_app
@@ -19,6 +22,7 @@ from marshmallow_utils.fields import (
19
22
  FormatEDTF,
20
23
  FormatTime,
21
24
  )
25
+ from invenio_rdm_records.services.schemas.parent import RDMParentSchema
22
26
  from marshmallow_utils.fields.babel import BabelFormatField
23
27
 
24
28
  from oarepo_runtime.i18n import gettext
@@ -26,6 +30,9 @@ from oarepo_runtime.i18n import lazy_gettext as _
26
30
 
27
31
  from .marshmallow import RDMBaseRecordSchema
28
32
 
33
+ from invenio_rdm_records.services.schemas.record import validate_scheme
34
+ from idutils import to_url
35
+
29
36
 
30
37
  def current_default_locale():
31
38
  """Get the Flask app's default locale."""
@@ -179,10 +186,44 @@ class AccessStatusField(ma.fields.Field):
179
186
  }
180
187
 
181
188
 
189
+ # to be able to have access to entire pids object
190
+ class PIDsField(Dict):
191
+ """Custom Dict field for PIDs that adds URLs after serialization."""
192
+
193
+ def _serialize(self, value, attr, obj, **kwargs):
194
+ """Serialize the PIDs and add URLs to them."""
195
+ serialized = super()._serialize(value, attr, obj, **kwargs)
196
+
197
+ if serialized:
198
+ for scheme, pid in serialized.items():
199
+ if scheme and pid and isinstance(pid, dict) and pid.get("identifier"):
200
+ url = to_url(pid["identifier"], scheme.lower(), url_scheme="https")
201
+ if url:
202
+ pid["url"] = url
203
+
204
+ return serialized
205
+
206
+
207
+ class InvenioRDMParentUISchema(RDMParentSchema):
208
+ """Parent schema."""
209
+
210
+ pids = PIDsField(
211
+ keys=SanitizedUnicode(validate=validate_scheme),
212
+ values=Nested(PIDSchema),
213
+ )
214
+
215
+
182
216
  class InvenioRDMUISchema(InvenioUISchema, RDMBaseRecordSchema):
217
+ """RDM UI schema."""
218
+
183
219
  is_draft = ma.fields.Boolean(dump_only=True)
184
220
  access_status = AccessStatusField(attribute="access", dump_only=True)
185
221
  versions = ma.fields.Nested(VersionsSchema, dump_only=True)
222
+ pids = PIDsField(
223
+ keys=SanitizedUnicode(validate=validate_scheme),
224
+ values=Nested(PIDSchema),
225
+ )
226
+ parent = ma.fields.Nested(InvenioRDMParentUISchema)
186
227
 
187
228
  def hide_tombstone(self, data):
188
229
  """Hide tombstone info if the record isn't deleted and metadata if it is."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: oarepo-runtime
3
- Version: 1.5.122
3
+ Version: 1.5.124
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -91,7 +91,7 @@ oarepo_runtime/services/search.py,sha256=t0WEe2VrbCzZ06-Jgz7C9-pc9y27BqAgTEXldEH
91
91
  oarepo_runtime/services/service.py,sha256=TI2ulEVlSR7HZnfPYltLl8Vf4O9fhJ7rHaV6G4HWbrc,1893
92
92
  oarepo_runtime/services/config/__init__.py,sha256=559w4vphVAipa420OwTsxGUP-b7idoqSIX13FSJyVz0,783
93
93
  oarepo_runtime/services/config/link_conditions.py,sha256=evPRd5XU76Ok4J-08bBfplbHZ019rl74FpJmO8iM5yg,3298
94
- oarepo_runtime/services/config/permissions_presets.py,sha256=jV3Ft7xFdBaeShoa3Q3Q-HHWP-wOX4XYDTRzWwUVL7g,7151
94
+ oarepo_runtime/services/config/permissions_presets.py,sha256=b1wm3JjL8KgkaH7VMkNfdMk5fXtf3X87rB7gkvaNxns,7369
95
95
  oarepo_runtime/services/config/service.py,sha256=s-dVbGkLICpsce6jgu7b5kzYFz9opWjSQFDBgbIhKio,4002
96
96
  oarepo_runtime/services/custom_fields/__init__.py,sha256=_gqMcA_I3rdEZcBtCuDjO4wdVCqFML5NzaccuPx5a3o,2565
97
97
  oarepo_runtime/services/custom_fields/mappings.py,sha256=3CIvjWzVRO3fZ2r-3taK1rwuLH9wj5Lguo-GvsbLBf4,7515
@@ -133,7 +133,7 @@ oarepo_runtime/services/schema/oneofschema.py,sha256=GnWH4Or_G5M0NgSmCoqMI6PBrJg
133
133
  oarepo_runtime/services/schema/polymorphic.py,sha256=bAbUoTIeDBiJPYPhpLEKKZekEdkHlpqkmNxk1hN3PDw,564
134
134
  oarepo_runtime/services/schema/rdm.py,sha256=dBy1KCJ_XYAN_cffoRqLfQVEdZOKwmSpqGdEP4OL64k,1280
135
135
  oarepo_runtime/services/schema/rdm_ui.py,sha256=KBTPAv4NkTNuhxIbOGzdBUXkwqKb-2q5EjWH2eTzc84,3430
136
- oarepo_runtime/services/schema/ui.py,sha256=hHbj1S-DW1WqgYX31f6UjarY4wrE-qFLpH3oUhvGLyE,6192
136
+ oarepo_runtime/services/schema/ui.py,sha256=KF4InRL1hHhYaUprE5S6iv_npyrtVp1N9OaQdSYxkvc,7595
137
137
  oarepo_runtime/services/schema/validation.py,sha256=VFOKSxQLHwFb7bW8BJAFXWe_iTAZFOfqOnb2Ko_Yxxc,2085
138
138
  oarepo_runtime/translations/default_translations.py,sha256=060GBlA1ghWxfeumo6NqxCCZDb-6OezOuF6pr-_GEOQ,104
139
139
  oarepo_runtime/translations/messages.pot,sha256=wr1vDKjsngqS9e5zQmSAsF3qUAtpQ41SUXwzEKRCnWw,2406
@@ -148,9 +148,9 @@ tests/marshmallow_to_json/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
148
148
  tests/marshmallow_to_json/test_datacite_ui_schema.py,sha256=82iLj8nW45lZOUewpWbLX3mpSkpa9lxo-vK-Qtv_1bU,48552
149
149
  tests/marshmallow_to_json/test_simple_schema.py,sha256=izZN9p0v6kovtSZ6AdxBYmK_c6ZOti2_z_wPT_zXIr0,1500
150
150
  tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
151
- oarepo_runtime-1.5.122.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
152
- oarepo_runtime-1.5.122.dist-info/METADATA,sha256=tP7D184oks8z2eHbQBeODo1i-_DMtEMYCB8IXQ_MtN8,4721
153
- oarepo_runtime-1.5.122.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
154
- oarepo_runtime-1.5.122.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
155
- oarepo_runtime-1.5.122.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
156
- oarepo_runtime-1.5.122.dist-info/RECORD,,
151
+ oarepo_runtime-1.5.124.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
152
+ oarepo_runtime-1.5.124.dist-info/METADATA,sha256=t1V9nLySEgmPYmIiMh3qOxk9VpxOOc-GNg12ei7YHTA,4721
153
+ oarepo_runtime-1.5.124.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
154
+ oarepo_runtime-1.5.124.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
155
+ oarepo_runtime-1.5.124.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
156
+ oarepo_runtime-1.5.124.dist-info/RECORD,,