oarepo-runtime 1.5.81__py3-none-any.whl → 1.5.83__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/records/mappings/__init__.py +0 -0
- oarepo_runtime/records/mappings/rdm_parent_mapping.json +39 -0
- oarepo_runtime/services/custom_fields/mappings.py +21 -3
- oarepo_runtime/services/permissions/generators.py +9 -4
- {oarepo_runtime-1.5.81.dist-info → oarepo_runtime-1.5.83.dist-info}/METADATA +1 -1
- {oarepo_runtime-1.5.81.dist-info → oarepo_runtime-1.5.83.dist-info}/RECORD +10 -8
- {oarepo_runtime-1.5.81.dist-info → oarepo_runtime-1.5.83.dist-info}/LICENSE +0 -0
- {oarepo_runtime-1.5.81.dist-info → oarepo_runtime-1.5.83.dist-info}/WHEEL +0 -0
- {oarepo_runtime-1.5.81.dist-info → oarepo_runtime-1.5.83.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-1.5.81.dist-info → oarepo_runtime-1.5.83.dist-info}/top_level.txt +0 -0
File without changes
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"is_verified": {
|
3
|
+
"type": "boolean"
|
4
|
+
},
|
5
|
+
"access": {
|
6
|
+
"properties": {
|
7
|
+
"owned_by": {
|
8
|
+
"properties": {
|
9
|
+
"user": {
|
10
|
+
"type": "keyword"
|
11
|
+
}
|
12
|
+
}
|
13
|
+
},
|
14
|
+
"grants": {
|
15
|
+
"properties": {
|
16
|
+
"subject": {
|
17
|
+
"type": "keyword"
|
18
|
+
},
|
19
|
+
"id": {
|
20
|
+
"type": "keyword"
|
21
|
+
},
|
22
|
+
"level": {
|
23
|
+
"type": "keyword"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
},
|
27
|
+
"grant_tokens": {
|
28
|
+
"type": "keyword"
|
29
|
+
},
|
30
|
+
"links": {
|
31
|
+
"properties": {
|
32
|
+
"id": {
|
33
|
+
"type": "keyword"
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
@@ -13,8 +13,12 @@ from invenio_search import current_search_client
|
|
13
13
|
from invenio_search.engine import dsl, search
|
14
14
|
from invenio_search.utils import build_alias_name
|
15
15
|
|
16
|
+
from deepmerge import always_merger
|
16
17
|
from oarepo_runtime.records.systemfields.mapping import MappingSystemFieldMixin
|
18
|
+
import json
|
19
|
+
import os
|
17
20
|
|
21
|
+
from pathlib import Path
|
18
22
|
|
19
23
|
class Mapping(InvenioMapping):
|
20
24
|
@classmethod
|
@@ -116,6 +120,16 @@ def prepare_cf_index(record_class, config, path=[]):
|
|
116
120
|
def prepare_parent_mapping(parent_class, config):
|
117
121
|
if not parent_class:
|
118
122
|
return
|
123
|
+
|
124
|
+
script_dir = str(Path(__file__).resolve().parent)
|
125
|
+
path_parts = script_dir.split('/')
|
126
|
+
path_parts = path_parts[:-2]
|
127
|
+
base_path = '/'.join(path_parts)
|
128
|
+
mapping_path = f"{base_path}/records/mappings/rdm_parent_mapping.json"
|
129
|
+
|
130
|
+
with open(mapping_path, 'r') as f:
|
131
|
+
rdm_parent = json.load(f)
|
132
|
+
|
119
133
|
parent_mapping = {
|
120
134
|
"parent": {
|
121
135
|
"type": "object",
|
@@ -142,7 +156,11 @@ def prepare_parent_mapping(parent_class, config):
|
|
142
156
|
},
|
143
157
|
}
|
144
158
|
}
|
145
|
-
|
159
|
+
parent_mapping_merged = always_merger.merge(parent_mapping, {
|
160
|
+
"parent": {
|
161
|
+
"properties": rdm_parent
|
162
|
+
}
|
163
|
+
})
|
146
164
|
# upload mapping
|
147
165
|
try:
|
148
166
|
record_index = dsl.Index(
|
@@ -151,7 +169,7 @@ def prepare_parent_mapping(parent_class, config):
|
|
151
169
|
),
|
152
170
|
using=current_search_client,
|
153
171
|
)
|
154
|
-
update_index(record_index, {},
|
172
|
+
update_index(record_index, {}, parent_mapping_merged)
|
155
173
|
|
156
174
|
if hasattr(config, "draft_cls"):
|
157
175
|
draft_index = dsl.Index(
|
@@ -160,7 +178,7 @@ def prepare_parent_mapping(parent_class, config):
|
|
160
178
|
),
|
161
179
|
using=current_search_client,
|
162
180
|
)
|
163
|
-
update_index(
|
181
|
+
update_index(record_index, {}, parent_mapping_merged)
|
164
182
|
|
165
183
|
except search.RequestError as e:
|
166
184
|
click.secho("An error occurred while creating parent mapping.", fg="red")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from flask_principal import RoleNeed, UserNeed
|
2
2
|
from invenio_records_permissions.generators import Generator
|
3
3
|
from invenio_search.engine import dsl
|
4
|
-
|
4
|
+
from flask import current_app
|
5
5
|
|
6
6
|
class RecordOwners(Generator):
|
7
7
|
"""Allows record owners."""
|
@@ -12,7 +12,10 @@ class RecordOwners(Generator):
|
|
12
12
|
# 'record' is required, so if not passed we default to empty array,
|
13
13
|
# i.e. superuser-access.
|
14
14
|
return []
|
15
|
-
|
15
|
+
if current_app.config.get('INVENIO_RDM_ENABLED', False):
|
16
|
+
owners = getattr(record.parent.access, "owned_by", None)
|
17
|
+
else:
|
18
|
+
owners = getattr(record.parent, "owners", None)
|
16
19
|
if owners is not None:
|
17
20
|
return [UserNeed(owner.id) for owner in owners]
|
18
21
|
return []
|
@@ -21,8 +24,10 @@ class RecordOwners(Generator):
|
|
21
24
|
"""Filters for current identity as owner."""
|
22
25
|
users = [n.value for n in identity.provides if n.method == "id"]
|
23
26
|
if users:
|
24
|
-
|
25
|
-
|
27
|
+
if current_app.config.get('INVENIO_RDM_ENABLED', False):
|
28
|
+
return dsl.Q("terms", **{"parent.access.owned_by.user": users})
|
29
|
+
else:
|
30
|
+
return dsl.Q("terms", **{"parent.owners.user": users})
|
26
31
|
|
27
32
|
class UserWithRole(Generator):
|
28
33
|
def __init__(self, *roles):
|
@@ -50,6 +50,8 @@ oarepo_runtime/records/dumpers/edtf_interval.py,sha256=YCShZAoqBQYaxVilEVotS-jXZ
|
|
50
50
|
oarepo_runtime/records/dumpers/multilingual_dumper.py,sha256=PbNFCLsiH4XV3E1v8xga_fzlcEImHy8OXn_UKh_8VBU,1090
|
51
51
|
oarepo_runtime/records/entity_resolvers/__init__.py,sha256=UiiIT54pUu9j7qPAPfqVp4UTnXnppp0c_LtKbFnyt6Y,383
|
52
52
|
oarepo_runtime/records/entity_resolvers/proxies.py,sha256=R92Cil_sTgX-sHJtdNv82yd-F3SUfsGSNCHdwI9Zfq8,1516
|
53
|
+
oarepo_runtime/records/mappings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
54
|
+
oarepo_runtime/records/mappings/rdm_parent_mapping.json,sha256=9yRjlGs8-TZZiKN9MtAzNhRzYq9AEJFY9E80FN0wYoM,647
|
53
55
|
oarepo_runtime/records/owners/__init__.py,sha256=R4hudCBqLRRzgCnkEjXIL7hSp068z-s6YOwYSkWyuaw,93
|
54
56
|
oarepo_runtime/records/owners/registry.py,sha256=fYgBuW5nBKn6pyz2OBgfNlynk64_yhQ9J7FzPk8QU1U,795
|
55
57
|
oarepo_runtime/records/relations/__init__.py,sha256=bDAgxl_LdKsqpGG3qluxAkQnn5u2ItJngnHQKkqzlkE,373
|
@@ -80,7 +82,7 @@ oarepo_runtime/services/config/link_conditions.py,sha256=evPRd5XU76Ok4J-08bBfplb
|
|
80
82
|
oarepo_runtime/services/config/permissions_presets.py,sha256=V0dMrikzTzTiM2NRtdGgTML7AtXlrlYZ_vm3btzbJd4,6472
|
81
83
|
oarepo_runtime/services/config/service.py,sha256=s-dVbGkLICpsce6jgu7b5kzYFz9opWjSQFDBgbIhKio,4002
|
82
84
|
oarepo_runtime/services/custom_fields/__init__.py,sha256=_gqMcA_I3rdEZcBtCuDjO4wdVCqFML5NzaccuPx5a3o,2565
|
83
|
-
oarepo_runtime/services/custom_fields/mappings.py,sha256=
|
85
|
+
oarepo_runtime/services/custom_fields/mappings.py,sha256=Y1d0s9lG_VThkzSNlxAS94_9eOFZe9N2C1hpYDZvnvI,7457
|
84
86
|
oarepo_runtime/services/entity/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
85
87
|
oarepo_runtime/services/entity/config.py,sha256=1jfdPrxSbMuKj7eOUNKRWTCPbBPyRV6MrWE4Vgf9rX0,399
|
86
88
|
oarepo_runtime/services/entity/schema.py,sha256=8TBpUFRITaBO7qCMz36cly1Hj4I1nLa9PeSAfWSa2YM,157
|
@@ -101,7 +103,7 @@ oarepo_runtime/services/files/__init__.py,sha256=K8MStrEQf_BUhvzhwPTF93Hkhwrd1dt
|
|
101
103
|
oarepo_runtime/services/files/components.py,sha256=x6Wd-vvkqTqB1phj2a6h42DNQksN8PuR2XKaOGoNHfw,2400
|
102
104
|
oarepo_runtime/services/files/service.py,sha256=8DH0Pefr9kilM2JnOb-UYsnqerE8Z1Mu4p6DOJ4j_ZU,608
|
103
105
|
oarepo_runtime/services/permissions/__init__.py,sha256=Cgin2Zr1fpaYr-aZcUotdmv0hsrPTUJVQt8ouvU8tuU,95
|
104
|
-
oarepo_runtime/services/permissions/generators.py,sha256=
|
106
|
+
oarepo_runtime/services/permissions/generators.py,sha256=OAJ_1W5eiLPkNvSXnWTDq0Z4-FU799qHa9tOufiOL3c,1722
|
105
107
|
oarepo_runtime/services/records/__init__.py,sha256=hIoa2fx1AkDr6c-MgY561U2oN9LFeUCtfbVnetpBUOg,78
|
106
108
|
oarepo_runtime/services/records/links.py,sha256=gVe-_hGkLtX7pd6sS6jTbRIhBby2FTn9PXyYPy3yxzs,737
|
107
109
|
oarepo_runtime/services/relations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -133,9 +135,9 @@ tests/marshmallow_to_json/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
133
135
|
tests/marshmallow_to_json/test_datacite_ui_schema.py,sha256=82iLj8nW45lZOUewpWbLX3mpSkpa9lxo-vK-Qtv_1bU,48552
|
134
136
|
tests/marshmallow_to_json/test_simple_schema.py,sha256=izZN9p0v6kovtSZ6AdxBYmK_c6ZOti2_z_wPT_zXIr0,1500
|
135
137
|
tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
136
|
-
oarepo_runtime-1.5.
|
137
|
-
oarepo_runtime-1.5.
|
138
|
-
oarepo_runtime-1.5.
|
139
|
-
oarepo_runtime-1.5.
|
140
|
-
oarepo_runtime-1.5.
|
141
|
-
oarepo_runtime-1.5.
|
138
|
+
oarepo_runtime-1.5.83.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
|
139
|
+
oarepo_runtime-1.5.83.dist-info/METADATA,sha256=nYdGP3yxN7VOCngVCzEe--YtLAiDdIESmcxGdL5zxqM,4720
|
140
|
+
oarepo_runtime-1.5.83.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
141
|
+
oarepo_runtime-1.5.83.dist-info/entry_points.txt,sha256=k7O5LZUOGsVeSpB7ulU0txBUNp1CVQG7Q7TJIVTPbzU,491
|
142
|
+
oarepo_runtime-1.5.83.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
|
143
|
+
oarepo_runtime-1.5.83.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|