oarepo-runtime 1.5.75__tar.gz → 1.5.76__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {oarepo_runtime-1.5.75/oarepo_runtime.egg-info → oarepo_runtime-1.5.76}/PKG-INFO +1 -1
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/utils.py +3 -1
- oarepo_runtime-1.5.76/oarepo_runtime/records/__init__.py +50 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/config/__init__.py +14 -0
- oarepo_runtime-1.5.76/oarepo_runtime/services/config/link_conditions.py +101 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/config/permissions_presets.py +3 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/results.py +7 -2
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76/oarepo_runtime.egg-info}/PKG-INFO +1 -1
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime.egg-info/SOURCES.txt +1 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/setup.cfg +1 -1
- oarepo_runtime-1.5.75/oarepo_runtime/records/__init__.py +0 -30
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/LICENSE +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/MANIFEST.in +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/README.md +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/assets.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/base.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/cf.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/check.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/configuration.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/fixtures.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/index.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/validate.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/asynchronous.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/catalogue.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/datastreams.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/errors.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/ext.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/fixtures.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/json.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/attachments.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/excel.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/json.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/service.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/yaml.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/semi_asynchronous.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/synchronous.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/transformers.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/types.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/attachments_file.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/attachments_service.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/service.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/utils.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/validation_errors.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/yaml.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/ext.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/ext_config.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/i18n/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/info/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/info/check.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/info/views.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/profile.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/proxies.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/dumpers/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/dumpers/edtf_interval.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/dumpers/multilingual_dumper.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/entity_resolvers/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/entity_resolvers/proxies.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/owners/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/owners/registry.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/base.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/internal.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/lookup.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/pid_relation.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/featured_file.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/has_draftcheck.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/icu.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/mapping.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/owner.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/record_status.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/selectors.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/synthetic.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/resources/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/resources/file_resource.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/resources/json_serializer.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/resources/localized_ui_json_serializer.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/components.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/config/service.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/custom_fields/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/custom_fields/mappings.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/entity/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/entity/config.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/entity/schema.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/entity/service.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/expansions/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/expansions/expandable_fields.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/expansions/service.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/base.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/date.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/enum.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/facet_groups_names.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/max_facet.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/nested_facet.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/params.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/year_histogram.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/files/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/files/components.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/files/service.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/generators.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/permissions/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/permissions/generators.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/records/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/records/links.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/relations/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/relations/components.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/relations/errors.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/relations/mapping.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/cf.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/i18n.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/i18n_ui.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/i18n_validation.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/marshmallow.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/marshmallow_to_json_schema.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/oneofschema.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/polymorphic.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/rdm.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/ui.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/validation.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/search.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/tasks.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/cs/LC_MESSAGES/messages.mo +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/cs/LC_MESSAGES/messages.po +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/default_translations.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/en/LC_MESSAGES/messages.mo +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/en/LC_MESSAGES/messages.po +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/messages.pot +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/uow.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/utils/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/utils/functools.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/utils/path.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime.egg-info/dependency_links.txt +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime.egg-info/entry_points.txt +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime.egg-info/requires.txt +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime.egg-info/top_level.txt +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/pyproject.toml +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/setup.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/tests/marshmallow_to_json/__init__.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/tests/marshmallow_to_json/test_datacite_ui_schema.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/tests/marshmallow_to_json/test_simple_schema.py +0 -0
- {oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/tests/pkg_data/__init__.py +0 -0
@@ -48,7 +48,6 @@ def get_record_service_for_record_deprecated(record):
|
|
48
48
|
if service_record == type(record):
|
49
49
|
return svc
|
50
50
|
|
51
|
-
|
52
51
|
def get_file_service_for_record_class(record_class):
|
53
52
|
if not record_class:
|
54
53
|
return None
|
@@ -60,6 +59,9 @@ def get_file_service_for_record_class(record_class):
|
|
60
59
|
continue
|
61
60
|
return svc
|
62
61
|
|
62
|
+
def get_file_service_for_file_record_class(file_record_class):
|
63
|
+
record_class = file_record_class.record_cls
|
64
|
+
return get_file_service_for_record_class(record_class)
|
63
65
|
|
64
66
|
def get_file_service_for_record_service(
|
65
67
|
record_service, check_draft_files=True, record=None
|
@@ -0,0 +1,50 @@
|
|
1
|
+
from typing import Type
|
2
|
+
|
3
|
+
from deprecated import deprecated
|
4
|
+
from invenio_records_resources.records import Record
|
5
|
+
|
6
|
+
|
7
|
+
def select_record_for_update(record_cls: Type[Record], persistent_identifier):
|
8
|
+
"""Select a record for update."""
|
9
|
+
resolved_record = record_cls.pid.resolve(persistent_identifier)
|
10
|
+
model_id = resolved_record.model.id
|
11
|
+
obj = record_cls.model_cls.query.filter_by(id=model_id).with_for_update().one()
|
12
|
+
return record_cls(obj.data, model=obj)
|
13
|
+
|
14
|
+
|
15
|
+
@deprecated("Moved to oarepo_runtime.services.config.link_conditions")
|
16
|
+
def is_published_record_function():
|
17
|
+
"""Shortcut for links to determine if record is a published.
|
18
|
+
|
19
|
+
This function is deprecated. Use oarepo_runtime.services.config.is_published_record instead.
|
20
|
+
"""
|
21
|
+
from oarepo_runtime.services.config.link_conditions import is_published_record
|
22
|
+
|
23
|
+
return is_published_record()
|
24
|
+
|
25
|
+
|
26
|
+
@deprecated("Moved to oarepo_runtime.services.config.link_conditions")
|
27
|
+
def is_draft_record_function():
|
28
|
+
"""Shortcut for links to determine if record is a draft record.
|
29
|
+
|
30
|
+
This function is deprecated. Use oarepo_runtime.services.config.is_draft_record instead.
|
31
|
+
"""
|
32
|
+
from oarepo_runtime.services.config.link_conditions import is_draft_record
|
33
|
+
|
34
|
+
return is_draft_record()
|
35
|
+
|
36
|
+
|
37
|
+
@deprecated("Moved to oarepo_runtime.services.config.link_conditions")
|
38
|
+
def has_draft_function():
|
39
|
+
"""Shortcut for links to determine if record is either a draft or a published one with a draft associated.
|
40
|
+
|
41
|
+
This function is deprecated. Use oarepo_runtime.services.config.has_draft instead.
|
42
|
+
"""
|
43
|
+
from oarepo_runtime.services.config.link_conditions import has_draft
|
44
|
+
|
45
|
+
return has_draft()
|
46
|
+
|
47
|
+
|
48
|
+
is_published_record = is_published_record_function()
|
49
|
+
is_draft = is_draft_record_function()
|
50
|
+
has_draft = has_draft_function()
|
@@ -1,3 +1,11 @@
|
|
1
|
+
from .link_conditions import (
|
2
|
+
has_draft,
|
3
|
+
has_permission,
|
4
|
+
has_permission_file_service,
|
5
|
+
has_published_record,
|
6
|
+
is_draft_record,
|
7
|
+
is_published_record,
|
8
|
+
)
|
1
9
|
from .permissions_presets import (
|
2
10
|
AuthenticatedPermissionPolicy,
|
3
11
|
EveryonePermissionPolicy,
|
@@ -12,4 +20,10 @@ __all__ = (
|
|
12
20
|
"ReadOnlyPermissionPolicy",
|
13
21
|
"EveryonePermissionPolicy",
|
14
22
|
"AuthenticatedPermissionPolicy",
|
23
|
+
"is_published_record",
|
24
|
+
"is_draft_record",
|
25
|
+
"has_draft",
|
26
|
+
"has_permission",
|
27
|
+
"has_permission_file_service",
|
28
|
+
"has_published_record",
|
15
29
|
)
|
@@ -0,0 +1,101 @@
|
|
1
|
+
from abc import abstractmethod
|
2
|
+
|
3
|
+
from invenio_pidstore.errors import PIDDoesNotExistError, PIDUnregistered
|
4
|
+
from invenio_records_resources.records.api import FileRecord
|
5
|
+
from invenio_records.api import RecordBase
|
6
|
+
from invenio_records_resources.records.api import Record
|
7
|
+
from logging import getLogger
|
8
|
+
from ...datastreams.utils import (
|
9
|
+
get_file_service_for_file_record_class,
|
10
|
+
get_file_service_for_record_class,
|
11
|
+
get_record_service_for_record,
|
12
|
+
)
|
13
|
+
log = getLogger(__name__)
|
14
|
+
|
15
|
+
class Condition:
|
16
|
+
|
17
|
+
@abstractmethod
|
18
|
+
def __call__(self, obj, ctx: dict):
|
19
|
+
raise NotImplementedError
|
20
|
+
|
21
|
+
def __and__(self, other):
|
22
|
+
return type(
|
23
|
+
"CompositeCondition",
|
24
|
+
(Condition,),
|
25
|
+
{"__call__": lambda _, obj, ctx: self(obj, ctx) and other(obj, ctx)},
|
26
|
+
)()
|
27
|
+
|
28
|
+
def __or__(self, other):
|
29
|
+
return type(
|
30
|
+
"CompositeCondition",
|
31
|
+
(Condition,),
|
32
|
+
{"__call__": lambda _, obj, ctx: self(obj, ctx) or other(obj, ctx)},
|
33
|
+
)()
|
34
|
+
|
35
|
+
|
36
|
+
class is_published_record(Condition):
|
37
|
+
"""Shortcut for links to determine if record is a published record."""
|
38
|
+
|
39
|
+
def __call__(self, obj: Record, ctx: dict):
|
40
|
+
return not getattr(obj, "is_draft", False)
|
41
|
+
|
42
|
+
|
43
|
+
class is_draft_record(Condition):
|
44
|
+
"""Shortcut for links to determine if record is a draft record."""
|
45
|
+
|
46
|
+
def __call__(self, obj: Record, ctx: dict):
|
47
|
+
return getattr(obj, "is_draft", False)
|
48
|
+
|
49
|
+
|
50
|
+
class has_draft(Condition):
|
51
|
+
"""Shortcut for links to determine if record is either a draft or a published one with a draft associated."""
|
52
|
+
|
53
|
+
def __call__(self, obj: Record, ctx: dict):
|
54
|
+
if getattr(obj, "is_draft", False):
|
55
|
+
return True
|
56
|
+
if getattr(obj, "has_draft", False):
|
57
|
+
return True
|
58
|
+
return False
|
59
|
+
|
60
|
+
|
61
|
+
class has_permission(Condition):
|
62
|
+
def __init__(self, action_name):
|
63
|
+
self.action_name = action_name
|
64
|
+
|
65
|
+
def __call__(self, obj: RecordBase, ctx: dict):
|
66
|
+
if isinstance(obj, FileRecord):
|
67
|
+
obj = obj.record
|
68
|
+
service = get_record_service_for_record(obj)
|
69
|
+
try:
|
70
|
+
return service.check_permission(
|
71
|
+
action_name=self.action_name, record=obj, **ctx
|
72
|
+
)
|
73
|
+
except Exception as e:
|
74
|
+
log.exception(f"Unexpected exception {e}.")
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
class has_permission_file_service(has_permission):
|
79
|
+
|
80
|
+
def __call__(self, obj: RecordBase, ctx: dict):
|
81
|
+
if isinstance(obj, FileRecord):
|
82
|
+
service = get_file_service_for_file_record_class(type(obj))
|
83
|
+
else:
|
84
|
+
service = get_file_service_for_record_class(type(obj))
|
85
|
+
try:
|
86
|
+
return service.check_permission(
|
87
|
+
action_name=self.action_name, record=obj, **ctx
|
88
|
+
)
|
89
|
+
except Exception as e:
|
90
|
+
log.exception(f"Unexpected exception {e}.")
|
91
|
+
|
92
|
+
|
93
|
+
class has_published_record(Condition):
|
94
|
+
|
95
|
+
def __call__(self, obj: Record, ctx: dict):
|
96
|
+
service = get_record_service_for_record(obj)
|
97
|
+
try:
|
98
|
+
service.record_cls.pid.resolve(obj["id"])
|
99
|
+
except (PIDUnregistered, PIDDoesNotExistError):
|
100
|
+
return False
|
101
|
+
return True
|
@@ -56,6 +56,7 @@ class ReadOnlyPermissionPolicy(RecordPermissionPolicy):
|
|
56
56
|
can_read_files = [AnyUser(), SystemProcess()]
|
57
57
|
can_update_files = [SystemProcess()]
|
58
58
|
can_delete_files = [SystemProcess()]
|
59
|
+
can_list_files = [SystemProcess()]
|
59
60
|
|
60
61
|
can_edit = [SystemProcess()]
|
61
62
|
can_new_version = [SystemProcess()]
|
@@ -92,6 +93,7 @@ class EveryonePermissionPolicy(RecordPermissionPolicy):
|
|
92
93
|
can_read_files = [SystemProcess(), AnyUser()]
|
93
94
|
can_update_files = [SystemProcess(), AnyUser()]
|
94
95
|
can_delete_files = [SystemProcess(), AnyUser()]
|
96
|
+
can_list_files = [SystemProcess(), AnyUser()]
|
95
97
|
|
96
98
|
can_edit = [SystemProcess(), AnyUser()]
|
97
99
|
can_new_version = [SystemProcess(), AnyUser()]
|
@@ -128,6 +130,7 @@ class AuthenticatedPermissionPolicy(RecordPermissionPolicy):
|
|
128
130
|
can_read_files = [SystemProcess(), AnyUser()]
|
129
131
|
can_update_files = [SystemProcess(), AuthenticatedUser()]
|
130
132
|
can_delete_files = [SystemProcess(), AuthenticatedUser()]
|
133
|
+
can_list_files = [SystemProcess(), AuthenticatedUser()]
|
131
134
|
|
132
135
|
can_edit = [SystemProcess(), AuthenticatedUser()]
|
133
136
|
can_new_version = [SystemProcess(), AuthenticatedUser()]
|
@@ -114,7 +114,12 @@ class RecordList(BaseRecordList):
|
|
114
114
|
record=record,
|
115
115
|
),
|
116
116
|
)
|
117
|
-
if self.
|
117
|
+
if hasattr(self._service.config, "links_search_item"):
|
118
|
+
links_tpl = self._service.config.search_item_links_template(
|
119
|
+
self._service.config.links_search_item
|
120
|
+
)
|
121
|
+
projection["links"] = links_tpl.expand(self._identity, record)
|
122
|
+
elif self._links_item_tpl:
|
118
123
|
projection["links"] = self._links_item_tpl.expand(
|
119
124
|
self._identity, record
|
120
125
|
)
|
@@ -122,7 +127,7 @@ class RecordList(BaseRecordList):
|
|
122
127
|
for c in self.components:
|
123
128
|
c.update_data(
|
124
129
|
identity=self._identity,
|
125
|
-
record=
|
130
|
+
record=record,
|
126
131
|
projection=projection,
|
127
132
|
expand=self._expand,
|
128
133
|
)
|
@@ -88,6 +88,7 @@ oarepo_runtime/services/generators.py
|
|
88
88
|
oarepo_runtime/services/results.py
|
89
89
|
oarepo_runtime/services/search.py
|
90
90
|
oarepo_runtime/services/config/__init__.py
|
91
|
+
oarepo_runtime/services/config/link_conditions.py
|
91
92
|
oarepo_runtime/services/config/permissions_presets.py
|
92
93
|
oarepo_runtime/services/config/service.py
|
93
94
|
oarepo_runtime/services/custom_fields/__init__.py
|
@@ -1,30 +0,0 @@
|
|
1
|
-
from typing import Type
|
2
|
-
|
3
|
-
from invenio_records_resources.records import Record
|
4
|
-
|
5
|
-
|
6
|
-
def select_record_for_update(record_cls: Type[Record], persistent_identifier):
|
7
|
-
"""Select a record for update."""
|
8
|
-
resolved_record = record_cls.pid.resolve(persistent_identifier)
|
9
|
-
model_id = resolved_record.model.id
|
10
|
-
obj = record_cls.model_cls.query.filter_by(id=model_id).with_for_update().one()
|
11
|
-
return record_cls(obj.data, model=obj)
|
12
|
-
|
13
|
-
|
14
|
-
def is_published_record(record, ctx):
|
15
|
-
"""Shortcut for links to determine if record is a published record."""
|
16
|
-
return not getattr(record, "is_draft", False)
|
17
|
-
|
18
|
-
|
19
|
-
def is_draft_record(record, ctx):
|
20
|
-
"""Shortcut for links to determine if record is a draft record."""
|
21
|
-
return getattr(record, "is_draft", False)
|
22
|
-
|
23
|
-
|
24
|
-
def has_draft(record, ctx):
|
25
|
-
"""Shortcut for links to determine if record is either a draft or a published one with a draft associated."""
|
26
|
-
if getattr(record, "is_draft", False):
|
27
|
-
return True
|
28
|
-
if getattr(record, "has_draft", False):
|
29
|
-
return True
|
30
|
-
return False
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/__init__.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/attachments.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/service.py
RENAMED
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/semi_asynchronous.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/service.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/dumpers/edtf_interval.py
RENAMED
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/entity_resolvers/__init__.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/entity_resolvers/proxies.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/__init__.py
RENAMED
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/internal.py
RENAMED
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/pid_relation.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/__init__.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/featured_file.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/mapping.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/owner.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/record_status.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/selectors.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/synthetic.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/custom_fields/__init__.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/custom_fields/mappings.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/expansions/__init__.py
RENAMED
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/expansions/service.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/facet_groups_names.py
RENAMED
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/nested_facet.py
RENAMED
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/year_histogram.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/permissions/__init__.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/permissions/generators.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/relations/__init__.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/relations/components.py
RENAMED
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/relations/mapping.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/i18n_validation.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/marshmallow.py
RENAMED
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/oneofschema.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/polymorphic.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/validation.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/default_translations.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/oarepo_runtime.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/tests/marshmallow_to_json/test_datacite_ui_schema.py
RENAMED
File without changes
|
{oarepo_runtime-1.5.75 → oarepo_runtime-1.5.76}/tests/marshmallow_to_json/test_simple_schema.py
RENAMED
File without changes
|
File without changes
|