oarepo-runtime 1.5.74__tar.gz → 1.5.76__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. {oarepo_runtime-1.5.74/oarepo_runtime.egg-info → oarepo_runtime-1.5.76}/PKG-INFO +1 -1
  2. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/utils.py +9 -3
  3. oarepo_runtime-1.5.76/oarepo_runtime/records/__init__.py +50 -0
  4. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/config/__init__.py +14 -0
  5. oarepo_runtime-1.5.76/oarepo_runtime/services/config/link_conditions.py +101 -0
  6. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/config/permissions_presets.py +3 -0
  7. oarepo_runtime-1.5.76/oarepo_runtime/services/records/__init__.py +3 -0
  8. oarepo_runtime-1.5.76/oarepo_runtime/services/records/links.py +21 -0
  9. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/results.py +7 -2
  10. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76/oarepo_runtime.egg-info}/PKG-INFO +1 -1
  11. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime.egg-info/SOURCES.txt +3 -0
  12. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/setup.cfg +1 -1
  13. oarepo_runtime-1.5.74/oarepo_runtime/records/__init__.py +0 -30
  14. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/LICENSE +0 -0
  15. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/MANIFEST.in +0 -0
  16. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/README.md +0 -0
  17. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/__init__.py +0 -0
  18. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/__init__.py +0 -0
  19. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/assets.py +0 -0
  20. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/base.py +0 -0
  21. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/cf.py +0 -0
  22. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/check.py +0 -0
  23. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/configuration.py +0 -0
  24. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/fixtures.py +0 -0
  25. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/index.py +0 -0
  26. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/cli/validate.py +0 -0
  27. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/__init__.py +0 -0
  28. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/asynchronous.py +0 -0
  29. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/catalogue.py +0 -0
  30. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/datastreams.py +0 -0
  31. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/errors.py +0 -0
  32. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/ext.py +0 -0
  33. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/fixtures.py +0 -0
  34. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/json.py +0 -0
  35. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/__init__.py +0 -0
  36. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/attachments.py +0 -0
  37. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/excel.py +0 -0
  38. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/json.py +0 -0
  39. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/service.py +0 -0
  40. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/readers/yaml.py +0 -0
  41. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/semi_asynchronous.py +0 -0
  42. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/synchronous.py +0 -0
  43. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/transformers.py +0 -0
  44. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/types.py +0 -0
  45. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/__init__.py +0 -0
  46. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/attachments_file.py +0 -0
  47. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/attachments_service.py +0 -0
  48. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/service.py +0 -0
  49. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/utils.py +0 -0
  50. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/validation_errors.py +0 -0
  51. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/datastreams/writers/yaml.py +0 -0
  52. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/ext.py +0 -0
  53. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/ext_config.py +0 -0
  54. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/i18n/__init__.py +0 -0
  55. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/info/__init__.py +0 -0
  56. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/info/check.py +0 -0
  57. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/info/views.py +0 -0
  58. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/profile.py +0 -0
  59. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/proxies.py +0 -0
  60. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/dumpers/__init__.py +0 -0
  61. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/dumpers/edtf_interval.py +0 -0
  62. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/dumpers/multilingual_dumper.py +0 -0
  63. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/entity_resolvers/__init__.py +0 -0
  64. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/entity_resolvers/proxies.py +0 -0
  65. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/owners/__init__.py +0 -0
  66. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/owners/registry.py +0 -0
  67. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/__init__.py +0 -0
  68. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/base.py +0 -0
  69. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/internal.py +0 -0
  70. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/lookup.py +0 -0
  71. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/relations/pid_relation.py +0 -0
  72. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/__init__.py +0 -0
  73. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/featured_file.py +0 -0
  74. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/has_draftcheck.py +0 -0
  75. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/icu.py +0 -0
  76. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/mapping.py +0 -0
  77. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/owner.py +0 -0
  78. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/record_status.py +0 -0
  79. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/selectors.py +0 -0
  80. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/records/systemfields/synthetic.py +0 -0
  81. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/resources/__init__.py +0 -0
  82. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/resources/file_resource.py +0 -0
  83. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/resources/json_serializer.py +0 -0
  84. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/resources/localized_ui_json_serializer.py +0 -0
  85. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/__init__.py +0 -0
  86. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/components.py +0 -0
  87. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/config/service.py +0 -0
  88. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/custom_fields/__init__.py +0 -0
  89. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/custom_fields/mappings.py +0 -0
  90. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/entity/__init__.py +0 -0
  91. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/entity/config.py +0 -0
  92. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/entity/schema.py +0 -0
  93. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/entity/service.py +0 -0
  94. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/expansions/__init__.py +0 -0
  95. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/expansions/expandable_fields.py +0 -0
  96. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/expansions/service.py +0 -0
  97. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/__init__.py +0 -0
  98. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/base.py +0 -0
  99. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/date.py +0 -0
  100. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/enum.py +0 -0
  101. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/facet_groups_names.py +0 -0
  102. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/max_facet.py +0 -0
  103. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/nested_facet.py +0 -0
  104. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/params.py +0 -0
  105. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/facets/year_histogram.py +0 -0
  106. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/files/__init__.py +0 -0
  107. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/files/components.py +0 -0
  108. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/files/service.py +0 -0
  109. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/generators.py +0 -0
  110. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/permissions/__init__.py +0 -0
  111. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/permissions/generators.py +0 -0
  112. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/relations/__init__.py +0 -0
  113. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/relations/components.py +0 -0
  114. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/relations/errors.py +0 -0
  115. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/relations/mapping.py +0 -0
  116. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/__init__.py +0 -0
  117. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/cf.py +0 -0
  118. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/i18n.py +0 -0
  119. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/i18n_ui.py +0 -0
  120. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/i18n_validation.py +0 -0
  121. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/marshmallow.py +0 -0
  122. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/marshmallow_to_json_schema.py +0 -0
  123. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/oneofschema.py +0 -0
  124. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/polymorphic.py +0 -0
  125. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/rdm.py +0 -0
  126. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/ui.py +0 -0
  127. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/schema/validation.py +0 -0
  128. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/services/search.py +0 -0
  129. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/tasks.py +0 -0
  130. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/cs/LC_MESSAGES/messages.mo +0 -0
  131. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/cs/LC_MESSAGES/messages.po +0 -0
  132. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/default_translations.py +0 -0
  133. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/en/LC_MESSAGES/messages.mo +0 -0
  134. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/en/LC_MESSAGES/messages.po +0 -0
  135. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/translations/messages.pot +0 -0
  136. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/uow.py +0 -0
  137. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/utils/__init__.py +0 -0
  138. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/utils/functools.py +0 -0
  139. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime/utils/path.py +0 -0
  140. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime.egg-info/dependency_links.txt +0 -0
  141. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime.egg-info/entry_points.txt +0 -0
  142. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime.egg-info/requires.txt +0 -0
  143. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/oarepo_runtime.egg-info/top_level.txt +0 -0
  144. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/pyproject.toml +0 -0
  145. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/setup.py +0 -0
  146. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/tests/marshmallow_to_json/__init__.py +0 -0
  147. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/tests/marshmallow_to_json/test_datacite_ui_schema.py +0 -0
  148. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/tests/marshmallow_to_json/test_simple_schema.py +0 -0
  149. {oarepo_runtime-1.5.74 → oarepo_runtime-1.5.76}/tests/pkg_data/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.5.74
3
+ Version: 1.5.76
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -15,12 +15,16 @@ def get_record_service_for_record(record):
15
15
  if not record:
16
16
  return None
17
17
  if "OAREPO_PRIMARY_RECORD_SERVICE" in current_app.config:
18
- service_id = current_app.config["OAREPO_PRIMARY_RECORD_SERVICE"][type(record)]
19
- return current_service_registry.get(service_id)
18
+ return get_record_service_for_record_class(type(record))
20
19
  else:
21
20
  return get_record_service_for_record_deprecated(record)
22
21
 
23
22
 
23
+ def get_record_service_for_record_class(record_cls):
24
+ service_id = current_app.config["OAREPO_PRIMARY_RECORD_SERVICE"][record_cls]
25
+ return current_service_registry.get(service_id)
26
+
27
+
24
28
  @deprecated(
25
29
  version="1.5.43", reason="Please recompile model to remove this deprecation warning"
26
30
  )
@@ -44,7 +48,6 @@ def get_record_service_for_record_deprecated(record):
44
48
  if service_record == type(record):
45
49
  return svc
46
50
 
47
-
48
51
  def get_file_service_for_record_class(record_class):
49
52
  if not record_class:
50
53
  return None
@@ -56,6 +59,9 @@ def get_file_service_for_record_class(record_class):
56
59
  continue
57
60
  return svc
58
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)
59
65
 
60
66
  def get_file_service_for_record_service(
61
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()]
@@ -0,0 +1,3 @@
1
+ from .links import pagination_links_html
2
+
3
+ __all__ = ("pagination_links_html",)
@@ -0,0 +1,21 @@
1
+ from invenio_records_resources.services.base.links import Link
2
+
3
+ def pagination_links_html(tpl: str)->dict[str, Link]:
4
+ """Create pagination links (prev/selv/next) from the same template."""
5
+ return {
6
+ "prev_html": Link(
7
+ tpl,
8
+ when=lambda pagination, ctx: pagination.has_prev,
9
+ vars=lambda pagination, vars: vars["args"].update(
10
+ {"page": pagination.prev_page.page}
11
+ ),
12
+ ),
13
+ "self_html": Link(tpl),
14
+ "next_html": Link(
15
+ tpl,
16
+ when=lambda pagination, ctx: pagination.has_next,
17
+ vars=lambda pagination, vars: vars["args"].update(
18
+ {"page": pagination.next_page.page}
19
+ ),
20
+ ),
21
+ }
@@ -114,7 +114,12 @@ class RecordList(BaseRecordList):
114
114
  record=record,
115
115
  ),
116
116
  )
117
- if self._links_item_tpl:
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=self._record,
130
+ record=record,
126
131
  projection=projection,
127
132
  expand=self._expand,
128
133
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.5.74
3
+ Version: 1.5.76
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -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
@@ -113,6 +114,8 @@ oarepo_runtime/services/files/components.py
113
114
  oarepo_runtime/services/files/service.py
114
115
  oarepo_runtime/services/permissions/__init__.py
115
116
  oarepo_runtime/services/permissions/generators.py
117
+ oarepo_runtime/services/records/__init__.py
118
+ oarepo_runtime/services/records/links.py
116
119
  oarepo_runtime/services/relations/__init__.py
117
120
  oarepo_runtime/services/relations/components.py
118
121
  oarepo_runtime/services/relations/errors.py
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = oarepo-runtime
3
- version = 1.5.74
3
+ version = 1.5.76
4
4
  description = A set of runtime extensions of Invenio repository
5
5
  authors = Alzbeta Pokorna
6
6
  readme = README.md
@@ -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