oarepo-runtime 1.5.107__py3-none-any.whl → 1.5.109__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.
@@ -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_records(
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
@@ -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_records(
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.107
3
+ Version: 1.5.109
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -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=GK5yGnJIjH60wGqqDoOfwMQQFQDLZhJpU4zBJOmABI8,2063
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=TI2ulEVlSR7HZnfPYltLl8Vf4O9fhJ7rHaV6G4HWbrc,1893
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
@@ -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.107.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
147
- oarepo_runtime-1.5.107.dist-info/METADATA,sha256=Z_a-shCynRJPgujCqljVNhXARmPVt8Q6lcJ1Eexd_oQ,4721
148
- oarepo_runtime-1.5.107.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
149
- oarepo_runtime-1.5.107.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
150
- oarepo_runtime-1.5.107.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
151
- oarepo_runtime-1.5.107.dist-info/RECORD,,
149
+ oarepo_runtime-1.5.109.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
150
+ oarepo_runtime-1.5.109.dist-info/METADATA,sha256=mUMQ-D-mCSYUFtvaX5WL18tv1L4a6JrclX6bua5RncI,4721
151
+ oarepo_runtime-1.5.109.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
152
+ oarepo_runtime-1.5.109.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
153
+ oarepo_runtime-1.5.109.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
154
+ oarepo_runtime-1.5.109.dist-info/RECORD,,