oarepo-runtime 1.5.106__py3-none-any.whl → 1.5.108__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.
@@ -5,22 +5,29 @@ from oarepo_runtime.services.relations.errors import InvalidRelationError
5
5
  from .base import Relation, RelationResult
6
6
  from .lookup import LookupResult
7
7
 
8
-
9
8
  class PIDRelationResult(RelationResult):
10
9
  def resolve(self, id_):
11
10
  """Resolve the value using the record class."""
12
11
  # TODO: handle permissions here !!!!!!
13
12
  try:
14
13
  pid_field_context = self.field.pid_field
15
- if hasattr(pid_field_context, "pid_type"):
16
- pid_type = pid_field_context.pid_type
17
- else:
14
+ try:
15
+ pid_type = getattr(pid_field_context, "pid_type", None)
16
+ except:
17
+ pass
18
+
19
+ if pid_type is None:
18
20
  pid_field = pid_field_context.field
19
- pid_type = (
20
- pid_field._provider.pid_type
21
- if pid_field._provider
22
- else pid_field._pid_type
23
- )
21
+ if pid_field._provider:
22
+ if hasattr(pid_field._provider, "pid_type"):
23
+ pid_type = pid_field._provider.pid_type
24
+ else:
25
+ pid_type = self.field.pid_field.record_cls.__name__
26
+ else:
27
+ if hasattr(pid_field, "_pid_type"):
28
+ pid_type = pid_field._pid_type
29
+ else:
30
+ pid_type = self.field.pid_field.record_cls.__name__
24
31
  except Exception as e:
25
32
  raise InvalidRelationError(
26
33
  f"PID type for field {self.field.key} has not been found or there was an exception accessing it.",
@@ -0,0 +1,50 @@
1
+ import marshmallow as ma
2
+ from flask_resources import (
3
+ JSONDeserializer,
4
+ JSONSerializer,
5
+ RequestBodyParser,
6
+ ResponseHandler,
7
+ )
8
+ from invenio_drafts_resources.resources import RecordResourceConfig
9
+ from invenio_rdm_records.resources.args import RDMSearchRequestArgsSchema
10
+ from invenio_rdm_records.resources.config import (
11
+ RDMRecordResourceConfig,
12
+ )
13
+ from invenio_records_resources.resources.records.headers import etag_headers
14
+
15
+ record_serializers = {
16
+ "application/json": ResponseHandler(JSONSerializer(), headers=etag_headers),
17
+ }
18
+
19
+
20
+ class BaseRecordResourceConfig(RDMRecordResourceConfig):
21
+ """Record resource configuration."""
22
+
23
+ blueprint_name = None
24
+ url_prefix = None
25
+
26
+ routes = RecordResourceConfig.routes
27
+
28
+ routes["delete-record"] = "/<pid_value>/delete"
29
+ routes["restore-record"] = "/<pid_value>/restore"
30
+ routes["set-record-quota"] = "/<pid_value>/quota"
31
+ routes["set-user-quota"] = "/users/<pid_value>/quota"
32
+ routes["all-prefix"] = "/all"
33
+
34
+ request_view_args = {
35
+ "pid_value": ma.fields.Str(),
36
+ }
37
+
38
+ request_read_args = {
39
+ "style": ma.fields.Str(),
40
+ "locale": ma.fields.Str(),
41
+ "include_deleted": ma.fields.Bool(),
42
+ }
43
+
44
+ request_body_parsers = {
45
+ "application/json": RequestBodyParser(JSONDeserializer()),
46
+ }
47
+
48
+ request_search_args = RDMSearchRequestArgsSchema
49
+
50
+ response_handlers = record_serializers
@@ -0,0 +1,59 @@
1
+ from flask import g
2
+ from flask_resources import (
3
+ resource_requestctx,
4
+ response_handler,
5
+ route,
6
+ )
7
+ from invenio_rdm_records.resources import RDMRecordResource
8
+ from invenio_records_resources.resources.records.resource import (
9
+ request_extra_args,
10
+ request_search_args,
11
+ request_view_args,
12
+ )
13
+ from invenio_records_resources.resources.records.utils import search_preference
14
+
15
+
16
+ class BaseRecordResource(RDMRecordResource):
17
+
18
+ def create_url_rules(self):
19
+ """Create the URL rules for the record resource."""
20
+
21
+ def p(route):
22
+ """Prefix a route with the URL prefix."""
23
+ return f"{self.config.url_prefix}{route}"
24
+
25
+ def s(route):
26
+ """Suffix a route with the URL prefix."""
27
+ return f"{route}{self.config.url_prefix}"
28
+
29
+ routes = self.config.routes
30
+ url_rules = super(RDMRecordResource, self).create_url_rules()
31
+ url_rules += [
32
+ route("DELETE", p(routes["delete-record"]), self.delete_record),
33
+ route("POST", p(routes["restore-record"]), self.restore_record),
34
+ route("POST", p(routes["set-record-quota"]), self.set_record_quota),
35
+ # TODO: move to users?
36
+ route("POST", routes["set-user-quota"], self.set_user_quota),
37
+ route("GET", s(routes["all-prefix"]), self.search_all_records),
38
+ ]
39
+
40
+ return url_rules
41
+
42
+ @request_extra_args
43
+ @request_search_args
44
+ @request_view_args
45
+ @response_handler(many=True)
46
+ def search_all_records(self):
47
+ """Perform a search over all records. Permission generators for search_all_records
48
+ and read_all_records must be in place and must be used to filter the results so that
49
+ no information is leaked.
50
+
51
+ GET /all/records
52
+ """
53
+ hits = self.service.search_all(
54
+ identity=g.identity,
55
+ params=resource_requestctx.args,
56
+ search_preference=search_preference(),
57
+ expand=resource_requestctx.args.get("expand", False),
58
+ )
59
+ return hits.to_dict(), 200
@@ -33,7 +33,7 @@ class RDMFunderVocabularyUISchema(DictOnlySchema):
33
33
 
34
34
  name = VocabularyI18nStrUIField()
35
35
 
36
- identifier = ma.fields.Nested(RDMIdentifierWithSchemaUISchema())
36
+ identifiers = ma.fields.List(ma.fields.Nested(RDMIdentifierWithSchemaUISchema()))
37
37
 
38
38
 
39
39
  class RDMRoleVocabularyUISchema(DictOnlySchema):
@@ -0,0 +1,61 @@
1
+ """An extension to invenio RDM service that includes a search across all records
2
+ (published, draft and deleted).
3
+ without any filtering. Permission `can_read_all_records` and `search_all_records`
4
+ were added and must be used to filter the results so that no information is leaked.
5
+ """
6
+
7
+ from invenio_rdm_records.services import RDMRecordService
8
+ from invenio_records_resources.services import LinksTemplate
9
+
10
+
11
+ class SearchAllRecordsService(RDMRecordService):
12
+ def search_all(
13
+ self,
14
+ identity,
15
+ params=None,
16
+ search_preference=None,
17
+ expand=False,
18
+ extra_filter=None,
19
+ **kwargs,
20
+ ):
21
+ """Search for drafts records matching the querystring."""
22
+ self.require_permission(
23
+ identity,
24
+ "search_all_records",
25
+ params=params,
26
+ extra_filter=extra_filter,
27
+ **kwargs,
28
+ )
29
+ # Prepare and execute the search
30
+ params = params or {}
31
+
32
+ search_opts = (
33
+ getattr(self.config, "search_all", None) or self.config.search_drafts
34
+ )
35
+
36
+ search_result = self._search(
37
+ "search_all",
38
+ identity,
39
+ params,
40
+ search_preference,
41
+ record_cls=self.draft_cls,
42
+ search_opts=search_opts,
43
+ extra_filter=extra_filter,
44
+ permission_action="read_all_records",
45
+ **kwargs,
46
+ ).execute()
47
+
48
+ return self.result_list(
49
+ self,
50
+ identity,
51
+ search_result,
52
+ params,
53
+ links_tpl=LinksTemplate(
54
+ getattr(self.config, "links_search_drafts")
55
+ or self.config.links_search_drafts,
56
+ context={"args": params},
57
+ ),
58
+ links_item_tpl=self.links_item_tpl,
59
+ expandable_fields=self.expandable_fields,
60
+ expand=expand,
61
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: oarepo-runtime
3
- Version: 1.5.106
3
+ Version: 1.5.108
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -65,7 +65,7 @@ oarepo_runtime/records/relations/__init__.py,sha256=bDAgxl_LdKsqpGG3qluxAkQnn5u2
65
65
  oarepo_runtime/records/relations/base.py,sha256=XQpRt6-MfIKIClZ0IoGJr0GGl2Ru3RcqMoowOxrFG_E,8981
66
66
  oarepo_runtime/records/relations/internal.py,sha256=OTp8iJqyl80sWDk0Q0AK42l6UsxZDABspVU_GwWza9o,1556
67
67
  oarepo_runtime/records/relations/lookup.py,sha256=wi3jPfOedazOmhOMrgu50PUETc1jfSdpmjK0wvOFsEM,848
68
- oarepo_runtime/records/relations/pid_relation.py,sha256=jKiwUEepJkOc0MRX3Etl5RQJw3t40rY7FOJCIPwOKmg,2932
68
+ oarepo_runtime/records/relations/pid_relation.py,sha256=G8ahoiQgp-PFPjQq0Fqu81z5YM7YKs8e2Hd_xqr3G8U,3290
69
69
  oarepo_runtime/records/systemfields/__init__.py,sha256=LL1R64RUakA_4r0IkTq9MtwqD5eV-AQaj5u96zkWa74,533
70
70
  oarepo_runtime/records/systemfields/featured_file.py,sha256=MbSaYR130_o5S9gEOblnChq-PVK4xGPGpSCrzwG3cwc,1720
71
71
  oarepo_runtime/records/systemfields/has_draftcheck.py,sha256=4JkMEefPLpqtPtlTgK3UT0KzTRgyw5_Qtkss2qcz5xk,1643
@@ -76,14 +76,17 @@ oarepo_runtime/records/systemfields/record_status.py,sha256=U3kem4-JkNsT17e0iAl3
76
76
  oarepo_runtime/records/systemfields/selectors.py,sha256=Q9jE1smSN3heT2LIpK_jB6bIRjll1kX0AW9AhTsIYiU,2830
77
77
  oarepo_runtime/records/systemfields/synthetic.py,sha256=UustvhzcDGuaNZLDeHbWwshoxQR-qRIuHDCct5RXmrI,4287
78
78
  oarepo_runtime/resources/__init__.py,sha256=v8BGrOTu_FjKzd0eozV7Q4GoGxyfybsL2cI-tbP5Pys,185
79
+ oarepo_runtime/resources/config.py,sha256=GEM3A7lvGgWUdhBR85uJbaQDKg2-Xk5U-Jm4JmogfFg,1414
79
80
  oarepo_runtime/resources/file_resource.py,sha256=Ta3bFce7l0xwqkkOMOEu9mxbB8BbKj5HUHRHmidhnl8,414
80
81
  oarepo_runtime/resources/json_serializer.py,sha256=82_-xQEtxKaPakv8R1oBAFbGnxskF_Ve4tcfcy4PetI,963
81
82
  oarepo_runtime/resources/localized_ui_json_serializer.py,sha256=3V9cJaG_e1PMXKVX_wKfBp1LmbeForwHyBNYdyha4uQ,1878
83
+ oarepo_runtime/resources/resource.py,sha256=BQ6sxgjHLAdQLtCMUggNG0Fq7NVRJPdVkpiHDH6tvDs,2055
82
84
  oarepo_runtime/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
85
  oarepo_runtime/services/components.py,sha256=0aqmuNbGCQhfOI22f6mM2DxuKSTqstGOGyisOiqw9KE,15481
84
86
  oarepo_runtime/services/generators.py,sha256=j87HitHA_w2awsz0C5IAAJ0qjg9JMtvdO3dvh6FQyfg,250
85
87
  oarepo_runtime/services/results.py,sha256=Ap2mUJHl3V4BSduTrBWPuco0inQVq0QsuCbVhez48uY,5705
86
88
  oarepo_runtime/services/search.py,sha256=t0WEe2VrbCzZ06-Jgz7C9-pc9y27BqAgTEXldEHskfk,9409
89
+ oarepo_runtime/services/service.py,sha256=A0VJ3jvMu7JTLcYKCAUH2LX7xXVxpm6Wm4rEnG358bU,1885
87
90
  oarepo_runtime/services/config/__init__.py,sha256=559w4vphVAipa420OwTsxGUP-b7idoqSIX13FSJyVz0,783
88
91
  oarepo_runtime/services/config/link_conditions.py,sha256=evPRd5XU76Ok4J-08bBfplbHZ019rl74FpJmO8iM5yg,3298
89
92
  oarepo_runtime/services/config/permissions_presets.py,sha256=jV3Ft7xFdBaeShoa3Q3Q-HHWP-wOX4XYDTRzWwUVL7g,7151
@@ -127,7 +130,7 @@ oarepo_runtime/services/schema/marshmallow_to_json_schema.py,sha256=VYLnVWHOoaxW
127
130
  oarepo_runtime/services/schema/oneofschema.py,sha256=GnWH4Or_G5M0NgSmCoqMI6PBrJg5AC9RHrcB5QDKRq0,6661
128
131
  oarepo_runtime/services/schema/polymorphic.py,sha256=bAbUoTIeDBiJPYPhpLEKKZekEdkHlpqkmNxk1hN3PDw,564
129
132
  oarepo_runtime/services/schema/rdm.py,sha256=BDmjWrBQmBN4QbQE9t7EUNUuZ4uCtAAtJ0bQvJWQLtc,1249
130
- oarepo_runtime/services/schema/rdm_ui.py,sha256=Vs9kOaQ0ZPPZpSqEXlu0vQrt-458Aci9u9T4YONSJLs,3026
133
+ oarepo_runtime/services/schema/rdm_ui.py,sha256=zXdaS6-YUaIcTkZDustqLufoHtpVKp5PcgUnwgJ0skE,3043
131
134
  oarepo_runtime/services/schema/ui.py,sha256=hHbj1S-DW1WqgYX31f6UjarY4wrE-qFLpH3oUhvGLyE,6192
132
135
  oarepo_runtime/services/schema/validation.py,sha256=VFOKSxQLHwFb7bW8BJAFXWe_iTAZFOfqOnb2Ko_Yxxc,2085
133
136
  oarepo_runtime/translations/default_translations.py,sha256=060GBlA1ghWxfeumo6NqxCCZDb-6OezOuF6pr-_GEOQ,104
@@ -143,9 +146,9 @@ tests/marshmallow_to_json/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
143
146
  tests/marshmallow_to_json/test_datacite_ui_schema.py,sha256=82iLj8nW45lZOUewpWbLX3mpSkpa9lxo-vK-Qtv_1bU,48552
144
147
  tests/marshmallow_to_json/test_simple_schema.py,sha256=izZN9p0v6kovtSZ6AdxBYmK_c6ZOti2_z_wPT_zXIr0,1500
145
148
  tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
146
- oarepo_runtime-1.5.106.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
147
- oarepo_runtime-1.5.106.dist-info/METADATA,sha256=nth_2oEsi3Ee8Ztqan5Tt-b7b72d25C7KrjbhpvL9eU,4721
148
- oarepo_runtime-1.5.106.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
149
- oarepo_runtime-1.5.106.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
150
- oarepo_runtime-1.5.106.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
151
- oarepo_runtime-1.5.106.dist-info/RECORD,,
149
+ oarepo_runtime-1.5.108.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
150
+ oarepo_runtime-1.5.108.dist-info/METADATA,sha256=pOE9SKeX_Zr1boKtFOupbeS3T6xxjxHasxx_Ea4Hu0c,4721
151
+ oarepo_runtime-1.5.108.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
152
+ oarepo_runtime-1.5.108.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
153
+ oarepo_runtime-1.5.108.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
154
+ oarepo_runtime-1.5.108.dist-info/RECORD,,