oarepo-runtime 1.5.38__tar.gz → 1.5.40__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. {oarepo_runtime-1.5.38/oarepo_runtime.egg-info → oarepo_runtime-1.5.40}/PKG-INFO +1 -1
  2. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/cli/fixtures.py +14 -7
  3. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/cli/index.py +12 -6
  4. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/fixtures.py +11 -5
  5. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/info/views.py +6 -6
  6. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/__init__.py +1 -1
  7. oarepo_runtime-1.5.40/oarepo_runtime/records/entity_resolvers/__init__.py +13 -0
  8. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/entity_resolvers/proxies.py +0 -2
  9. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/systemfields/owner.py +10 -4
  10. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/components.py +10 -0
  11. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/facets/params.py +13 -0
  12. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/files/components.py +17 -10
  13. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/results.py +6 -6
  14. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/schema/__init__.py +9 -7
  15. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/schema/i18n.py +15 -4
  16. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/schema/i18n_ui.py +16 -7
  17. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/schema/oneofschema.py +1 -1
  18. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/schema/polymorphic.py +3 -1
  19. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40/oarepo_runtime.egg-info}/PKG-INFO +1 -1
  20. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/setup.cfg +1 -1
  21. oarepo_runtime-1.5.38/oarepo_runtime/records/entity_resolvers/__init__.py +0 -6
  22. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/LICENSE +0 -0
  23. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/MANIFEST.in +0 -0
  24. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/README.md +0 -0
  25. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/__init__.py +0 -0
  26. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/cli/__init__.py +0 -0
  27. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/cli/assets.py +0 -0
  28. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/cli/base.py +0 -0
  29. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/cli/cf.py +0 -0
  30. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/cli/check.py +0 -0
  31. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/cli/configuration.py +0 -0
  32. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/cli/validate.py +0 -0
  33. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/__init__.py +0 -0
  34. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/asynchronous.py +0 -0
  35. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/catalogue.py +0 -0
  36. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/datastreams.py +0 -0
  37. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/errors.py +0 -0
  38. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/ext.py +0 -0
  39. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/json.py +0 -0
  40. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/readers/__init__.py +0 -0
  41. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/readers/attachments.py +0 -0
  42. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/readers/excel.py +0 -0
  43. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/readers/json.py +0 -0
  44. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/readers/service.py +0 -0
  45. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/readers/yaml.py +0 -0
  46. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/semi_asynchronous.py +0 -0
  47. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/synchronous.py +0 -0
  48. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/transformers.py +0 -0
  49. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/types.py +0 -0
  50. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/utils.py +0 -0
  51. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/writers/__init__.py +0 -0
  52. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/writers/attachments_file.py +0 -0
  53. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/writers/attachments_service.py +0 -0
  54. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/writers/service.py +0 -0
  55. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/writers/utils.py +0 -0
  56. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/writers/validation_errors.py +0 -0
  57. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/datastreams/writers/yaml.py +0 -0
  58. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/ext.py +0 -0
  59. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/ext_config.py +0 -0
  60. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/i18n/__init__.py +0 -0
  61. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/info/__init__.py +0 -0
  62. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/profile.py +0 -0
  63. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/proxies.py +0 -0
  64. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/dumpers/__init__.py +0 -0
  65. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/dumpers/edtf_interval.py +0 -0
  66. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/dumpers/multilingual_dumper.py +0 -0
  67. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/owners/__init__.py +0 -0
  68. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/owners/registry.py +0 -0
  69. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/relations/__init__.py +0 -0
  70. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/relations/base.py +0 -0
  71. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/relations/internal.py +0 -0
  72. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/relations/lookup.py +0 -0
  73. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/relations/pid_relation.py +0 -0
  74. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/systemfields/__init__.py +0 -0
  75. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/systemfields/featured_file.py +0 -0
  76. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/systemfields/has_draftcheck.py +0 -0
  77. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/systemfields/icu.py +0 -0
  78. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/systemfields/mapping.py +0 -0
  79. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/systemfields/record_status.py +0 -0
  80. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/systemfields/selectors.py +0 -0
  81. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/records/systemfields/synthetic.py +2 -2
  82. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/resources/__init__.py +0 -0
  83. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/resources/file_resource.py +0 -0
  84. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/resources/localized_ui_json_serializer.py +0 -0
  85. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/__init__.py +0 -0
  86. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/config/__init__.py +0 -0
  87. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/config/permissions_presets.py +0 -0
  88. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/config/service.py +0 -0
  89. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/custom_fields/__init__.py +0 -0
  90. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/custom_fields/mappings.py +0 -0
  91. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/expansions/__init__.py +0 -0
  92. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/expansions/expandable_fields.py +0 -0
  93. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/expansions/service.py +0 -0
  94. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/facets/__init__.py +0 -0
  95. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/facets/base.py +0 -0
  96. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/facets/date.py +0 -0
  97. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/facets/enum.py +0 -0
  98. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/facets/facet_groups_names.py +0 -0
  99. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/facets/max_facet.py +0 -0
  100. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/facets/nested_facet.py +0 -0
  101. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/files/__init__.py +0 -0
  102. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/files/service.py +0 -0
  103. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/generators.py +0 -0
  104. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/relations/__init__.py +0 -0
  105. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/relations/components.py +0 -0
  106. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/relations/errors.py +0 -0
  107. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/relations/mapping.py +0 -0
  108. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/schema/cf.py +0 -0
  109. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/schema/i18n_validation.py +0 -0
  110. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/schema/marshmallow.py +0 -0
  111. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/schema/ui.py +0 -0
  112. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/schema/validation.py +0 -0
  113. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/services/search.py +0 -0
  114. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/translations/cs/LC_MESSAGES/messages.mo +0 -0
  115. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/translations/cs/LC_MESSAGES/messages.po +0 -0
  116. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/translations/default_translations.py +0 -0
  117. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/translations/en/LC_MESSAGES/messages.mo +0 -0
  118. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/translations/en/LC_MESSAGES/messages.po +0 -0
  119. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/translations/jinjax_messages.jinja +0 -0
  120. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/translations/messages.pot +0 -0
  121. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/uow.py +0 -0
  122. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/utils/__init__.py +0 -0
  123. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/utils/functools.py +0 -0
  124. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime/utils/path.py +0 -0
  125. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime.egg-info/SOURCES.txt +0 -0
  126. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime.egg-info/dependency_links.txt +0 -0
  127. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime.egg-info/entry_points.txt +0 -0
  128. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime.egg-info/requires.txt +0 -0
  129. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/oarepo_runtime.egg-info/top_level.txt +0 -0
  130. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/pyproject.toml +0 -0
  131. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/setup.py +0 -0
  132. {oarepo_runtime-1.5.38 → oarepo_runtime-1.5.40}/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.38
3
+ Version: 1.5.40
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -3,8 +3,14 @@ import tqdm
3
3
  from flask import current_app
4
4
  from flask.cli import with_appcontext
5
5
  from flask_login import login_user
6
- from flask_principal import Identity, identity_changed, identity_loaded, UserNeed, RoleNeed
7
- from invenio_access.permissions import system_identity, any_user, authenticated_user
6
+ from flask_principal import (
7
+ Identity,
8
+ RoleNeed,
9
+ UserNeed,
10
+ identity_changed,
11
+ identity_loaded,
12
+ )
13
+ from invenio_access.permissions import any_user, authenticated_user, system_identity
8
14
  from invenio_accounts.models import User
9
15
 
10
16
  from oarepo_runtime.cli import oarepo
@@ -39,7 +45,9 @@ def fixtures():
39
45
  "will be committed in a single transaction and indexed together",
40
46
  )
41
47
  @click.option("--batch-size", help="Alias for --bulk-size", type=int)
42
- @click.option("--identity", help="Email of the identity that will be used to import the data")
48
+ @click.option(
49
+ "--identity", help="Email of the identity that will be used to import the data"
50
+ )
43
51
  @with_appcontext
44
52
  def load(
45
53
  fixture_dir=None,
@@ -50,7 +58,7 @@ def load(
50
58
  bulk_size=100,
51
59
  on_background=False,
52
60
  batch_size=None,
53
- identity=None
61
+ identity=None,
54
62
  ):
55
63
  """Loads fixtures"""
56
64
  if batch_size:
@@ -77,12 +85,11 @@ def load(
77
85
  identity.provides.add(any_user)
78
86
  identity.provides.add(authenticated_user)
79
87
  identity.provides.add(UserNeed(user.id))
80
- for role in getattr(user, 'roles', []):
88
+ for role in getattr(user, "roles", []):
81
89
  identity.provides.add(RoleNeed(role.name))
82
90
  # TODO: community roles ...
83
91
 
84
92
  with current_app.wsgi_app.mounts["/api"].app_context():
85
-
86
93
  load_fixtures(
87
94
  fixture_dir,
88
95
  _make_list(include),
@@ -93,7 +100,7 @@ def load(
93
100
  datastreams_impl=(
94
101
  AsynchronousDataStream if on_background else SynchronousDataStream
95
102
  ),
96
- identity=identity
103
+ identity=identity,
97
104
  )
98
105
  if not on_background:
99
106
  _show_stats(callback, "Load fixtures")
@@ -112,14 +112,19 @@ def reindex(model, bulk_size, verbose):
112
112
  service = current_service_registry.get(service_id)
113
113
  except KeyError:
114
114
  click.secho(f"Service {service_id} not in known services:", color="red")
115
- for known_service_id, known_service in sorted(current_service_registry._services.items()):
116
- click.secho(f" {known_service_id} -> {type(known_service).__module__}.{type(known_service).__name__}", color="red")
115
+ for known_service_id, known_service in sorted(
116
+ current_service_registry._services.items()
117
+ ):
118
+ click.secho(
119
+ f" {known_service_id} -> {type(known_service).__module__}.{type(known_service).__name__}",
120
+ color="red",
121
+ )
117
122
  sys.exit(1)
118
123
  record_class = getattr(service.config, "record_cls", None)
119
124
 
120
125
  id_generators = []
121
126
 
122
- record_generator = RECORD_GENERATORS.get(service_id, model_records_generator)
127
+ record_generator = RECORD_GENERATORS.get(service_id, model_records_generator)
123
128
 
124
129
  if record_class and hasattr(service, "indexer"):
125
130
  try:
@@ -223,9 +228,11 @@ def model_records_generator(model_class):
223
228
  except Exception as e:
224
229
  click.secho(f"Could not index {model_class}: {e}", fg="red", file=sys.stderr)
225
230
 
231
+
226
232
  def users_record_generator(model_class):
227
233
  from invenio_accounts.models import User
228
234
  from invenio_users_resources.records.api import UserAggregate
235
+
229
236
  try:
230
237
  for x in db.session.query(User.id):
231
238
  rec_id = x[0]
@@ -233,6 +240,5 @@ def users_record_generator(model_class):
233
240
  except Exception as e:
234
241
  click.secho(f"Could not index {model_class}: {e}", fg="red", file=sys.stderr)
235
242
 
236
- RECORD_GENERATORS = {
237
- 'users': users_record_generator
238
- }
243
+
244
+ RECORD_GENERATORS = {"users": users_record_generator}
@@ -35,7 +35,7 @@ def load_fixtures(
35
35
  callback: FixturesCallback = None,
36
36
  batch_size=100,
37
37
  datastreams_impl=SynchronousDataStream,
38
- identity=system_identity
38
+ identity=system_identity,
39
39
  ):
40
40
  """
41
41
  Loads fixtures. If fixture dir is set, fixtures are loaded from that directory first.
@@ -64,7 +64,7 @@ def load_fixtures(
64
64
  callback,
65
65
  batch_size=batch_size,
66
66
  datastreams_impl=datastreams_impl,
67
- identity=identity
67
+ identity=identity,
68
68
  )
69
69
 
70
70
  if system_fixtures:
@@ -94,13 +94,19 @@ def load_fixtures(
94
94
  callback,
95
95
  batch_size=batch_size,
96
96
  datastreams_impl=datastreams_impl,
97
- identity=identity
97
+ identity=identity,
98
98
  )
99
99
 
100
100
 
101
101
  def _load_fixtures_from_catalogue(
102
- catalogue, fixtures, include, exclude, callback, batch_size, datastreams_impl,
103
- identity=system_identity
102
+ catalogue,
103
+ fixtures,
104
+ include,
105
+ exclude,
106
+ callback,
107
+ batch_size,
108
+ datastreams_impl,
109
+ identity=system_identity,
104
110
  ):
105
111
  for catalogue_datastream in catalogue.get_datastreams():
106
112
  if catalogue_datastream.stream_name in fixtures:
@@ -273,7 +273,6 @@ class InfoResource(Resource):
273
273
  return None
274
274
  return service
275
275
 
276
-
277
276
  def _get_service_class(self, model_data):
278
277
  service_id = model_data["service"]["class"]
279
278
  return obj_or_import_string(service_id)
@@ -301,7 +300,7 @@ def get_package_version(package_name):
301
300
  def api_url_for(endpoint, _external=True, **values):
302
301
  """API url_for."""
303
302
  try:
304
- api_app = current_app.wsgi_app.mounts['/api']
303
+ api_app = current_app.wsgi_app.mounts["/api"]
305
304
  except:
306
305
  api_app = current_app
307
306
 
@@ -309,14 +308,15 @@ def api_url_for(endpoint, _external=True, **values):
309
308
  site_url = current_app.config["SITE_UI_URL"]
310
309
  current_request_context = _cv_request.get()
311
310
  try:
312
- new_context = RequestContext(app=api_app,
313
- environ=request.environ)
311
+ new_context = RequestContext(app=api_app, environ=request.environ)
314
312
  _cv_request.set(new_context)
315
313
  base_url = api_app.url_for(endpoint, **values, _external=_external)
316
314
  if base_url.startswith(site_api_url):
317
315
  return base_url
318
316
  if base_url.startswith(site_url):
319
317
  return base_url.replace(site_url, site_api_url)
320
- raise ValueError(f"URL {base_url} does not start with {site_url} or {site_api_url}")
318
+ raise ValueError(
319
+ f"URL {base_url} does not start with {site_url} or {site_api_url}"
320
+ )
321
321
  finally:
322
- _cv_request.set(current_request_context)
322
+ _cv_request.set(current_request_context)
@@ -25,6 +25,6 @@ def has_draft(record, ctx):
25
25
  """Shortcut for links to determine if record is either a draft or a published one with a draft associated."""
26
26
  if getattr(record, "is_draft", False):
27
27
  return True
28
- if getattr(record, 'has_draft', False):
28
+ if getattr(record, "has_draft", False):
29
29
  return True
30
30
  return False
@@ -0,0 +1,13 @@
1
+ from invenio_records_resources.references import EntityResolver, RecordResolver
2
+ from invenio_users_resources.entity_resolvers import GroupResolver, UserResolver
3
+
4
+ from oarepo_runtime.records.entity_resolvers.proxies import DraftProxy, RecordProxy
5
+
6
+ __all__ = [
7
+ "DraftProxy",
8
+ "UserResolver",
9
+ "GroupResolver",
10
+ "RecordResolver",
11
+ "EntityResolver",
12
+ "RecordProxy",
13
+ ]
@@ -1,9 +1,7 @@
1
1
  from invenio_pidstore.errors import PIDUnregistered
2
-
3
2
  from invenio_records_resources.references.entity_resolvers.records import (
4
3
  RecordProxy as InvenioRecordProxy,
5
4
  )
6
-
7
5
  from sqlalchemy.exc import NoResultFound
8
6
 
9
7
 
@@ -17,7 +17,6 @@ from oarepo_runtime.records.systemfields import MappingSystemFieldMixin
17
17
 
18
18
 
19
19
  class OwnerRelationManager:
20
-
21
20
  def __init__(self, record_id, serialized_owners):
22
21
  self._serialized_owners = serialized_owners
23
22
  self._deserialized_owners = None
@@ -33,9 +32,13 @@ class OwnerRelationManager:
33
32
  if self._serialized_owners is None:
34
33
  deserialized_owners = []
35
34
  for deserialized_owner in self._deserialized_owners or []:
36
- serialized_owner = OwnerEntityResolverRegistry.reference_entity(deserialized_owner)
35
+ serialized_owner = OwnerEntityResolverRegistry.reference_entity(
36
+ deserialized_owner
37
+ )
37
38
  if serialized_owner is None:
38
- raise ValueError(f'failed serialize owner; owner - {deserialized_owner}')
39
+ raise ValueError(
40
+ f"failed serialize owner; owner - {deserialized_owner}"
41
+ )
39
42
  deserialized_owners.append(serialized_owner)
40
43
  self._serialized_owners = deserialized_owners
41
44
  return self._serialized_owners
@@ -44,7 +47,9 @@ class OwnerRelationManager:
44
47
  if self._deserialized_owners is None:
45
48
  self._deserialized_owners = set()
46
49
  for ref in self._serialized_owners or []:
47
- self._deserialized_owners.add(OwnerEntityResolverRegistry.resolve_reference(ref))
50
+ self._deserialized_owners.add(
51
+ OwnerEntityResolverRegistry.resolve_reference(ref)
52
+ )
48
53
  self._serialized_owners = None
49
54
 
50
55
  def add(self, owner):
@@ -63,6 +68,7 @@ class OwnerRelationManager:
63
68
  self._resolve()
64
69
  return iter(self._deserialized_owners)
65
70
 
71
+
66
72
  class OwnersField(MappingSystemFieldMixin, SystemField):
67
73
  """Communites system field for managing relations to communities."""
68
74
 
@@ -41,3 +41,13 @@ class OwnersComponent(ServiceComponent):
41
41
  if new_term:
42
42
  return search.filter(new_term)
43
43
  return search
44
+
45
+
46
+ from datetime import datetime
47
+
48
+
49
+ class DateIssuedComponent(ServiceComponent):
50
+ def publish(self, identity, data=None, record=None, errors=None, **kwargs):
51
+ """Create a new record."""
52
+ if "dateIssued" not in record["metadata"]:
53
+ record["metadata"]["dateIssued"] = datetime.today().strftime("%Y-%m-%d")
@@ -78,6 +78,19 @@ class GroupedFacetsParam(FacetsParam):
78
78
 
79
79
  return search
80
80
 
81
+ def filter(self, search):
82
+ """Apply a post filter on the search."""
83
+ if not self._filters:
84
+ return search
85
+
86
+ filters = list(self._filters.values())
87
+
88
+ _filter = filters[0]
89
+ for f in filters[1:]:
90
+ _filter &= f
91
+
92
+ return search.filter(_filter)
93
+
81
94
  def apply(self, identity, search, params):
82
95
  """Evaluate the facets on the search."""
83
96
  facets_values = params.pop("facets", {})
@@ -1,10 +1,11 @@
1
1
  import mimetypes
2
2
  import os
3
+
3
4
  from invenio_records_resources.services.files.components import FileServiceComponent
4
5
  from marshmallow.exceptions import ValidationError
5
6
 
6
- class AllowedFileTypesComponent(FileServiceComponent):
7
7
 
8
+ class AllowedFileTypesComponent(FileServiceComponent):
8
9
  def guess_content_type(self, filename: str | None) -> str | None:
9
10
  if filename:
10
11
  return mimetypes.guess_type(filename)[0] or "application/octet-stream"
@@ -22,10 +23,7 @@ class AllowedFileTypesComponent(FileServiceComponent):
22
23
  ext_guessed = mimetypes.guess_extension(mimetype)
23
24
 
24
25
  # Check if a valid extension is guessed and it's not the default mimetype
25
- if (
26
- ext_guessed is not None
27
- and mimetype != "application/octet-stream"
28
- ):
26
+ if ext_guessed is not None and mimetype != "application/octet-stream":
29
27
  return ext_guessed[1:]
30
28
 
31
29
  # Support non-standard file extensions that cannot be guessed
@@ -48,8 +46,17 @@ class AllowedFileTypesComponent(FileServiceComponent):
48
46
  for file in list_files:
49
47
  allowed_type = self.guess_content_type(file)
50
48
  allowed_ext = self.guess_extension(file, allowed_type)
51
- if len(self.allowed_mimetypes) > 0 and allowed_type not in self.allowed_mimetypes:
52
- raise ValidationError(f"Mimetype not supported, supported mimetypes: {self.allowed_mimetypes}")
53
- elif len(self.allowed_extensions) > 0 and allowed_ext not in self.allowed_extensions:
54
- raise ValidationError(f"Extension not supported, supported extensions: {self.allowed_extensions}")
55
-
49
+ if (
50
+ len(self.allowed_mimetypes) > 0
51
+ and allowed_type not in self.allowed_mimetypes
52
+ ):
53
+ raise ValidationError(
54
+ f"Mimetype not supported, supported mimetypes: {self.allowed_mimetypes}"
55
+ )
56
+ elif (
57
+ len(self.allowed_extensions) > 0
58
+ and allowed_ext not in self.allowed_extensions
59
+ ):
60
+ raise ValidationError(
61
+ f"Extension not supported, supported extensions: {self.allowed_extensions}"
62
+ )
@@ -43,15 +43,15 @@ class RecordList(BaseRecordList):
43
43
  return result
44
44
 
45
45
  for key in result.keys():
46
- if 'buckets' in result[key]:
47
- for bucket in result[key]['buckets']:
48
- val = bucket['key']
49
- label = bucket.get('label', '')
46
+ if "buckets" in result[key]:
47
+ for bucket in result[key]["buckets"]:
48
+ val = bucket["key"]
49
+ label = bucket.get("label", "")
50
50
 
51
51
  if not isinstance(val, str):
52
- bucket['key'] = str(val)
52
+ bucket["key"] = str(val)
53
53
  if not isinstance(label, str):
54
- bucket['label'] = str(label)
54
+ bucket["label"] = str(label)
55
55
  return result
56
56
  except AttributeError:
57
57
  return None
@@ -3,11 +3,11 @@ from .polymorphic import PolymorphicSchema
3
3
 
4
4
  def consistent_resolution(*classes):
5
5
  """
6
- A helper function to solve resolution order of classes.
7
- If the classes are in a correct mro order, it will return
8
- them in the same order. Otherwise it will try to reorder
9
- them and remove those that are already contained in mro
10
- of others.
6
+ A helper function to solve resolution order of classes.
7
+ If the classes are in a correct mro order, it will return
8
+ them in the same order. Otherwise it will try to reorder
9
+ them and remove those that are already contained in mro
10
+ of others.
11
11
  """
12
12
 
13
13
  # remove classes that are already in mro of others
@@ -35,8 +35,10 @@ def consistent_resolution(*classes):
35
35
 
36
36
  bases = ", ".join(cls.__name__ for cls in filtered_classes)
37
37
  orig_bases = ", ".join(cls.__name__ for cls in classes)
38
- raise TypeError(f"Cannot create a consistent method resolution order (MRO) "
39
- f"for bases {orig_bases}, tried {bases}")
38
+ raise TypeError(
39
+ f"Cannot create a consistent method resolution order (MRO) "
40
+ f"for bases {orig_bases}, tried {bases}"
41
+ )
40
42
 
41
43
 
42
44
  __all__ = ("PolymorphicSchema", "consistent_resolution")
@@ -1,5 +1,6 @@
1
- from functools import lru_cache
2
1
  import importlib
2
+ from functools import lru_cache
3
+
3
4
  import langcodes
4
5
  from invenio_base.utils import obj_or_import_string
5
6
  from marshmallow import Schema, ValidationError, fields, validates
@@ -11,7 +12,9 @@ it for each project.
11
12
 
12
13
 
13
14
  @lru_cache
14
- def get_i18n_schema(lang_name, value_name, value_field="marshmallow_utils.fields.SanitizedHTML"):
15
+ def get_i18n_schema(
16
+ lang_name, value_name, value_field="marshmallow_utils.fields.SanitizedHTML"
17
+ ):
15
18
  @validates(lang_name)
16
19
  def validate_lang(self, value):
17
20
  if value != "_" and not langcodes.Language.get(value).is_valid():
@@ -31,7 +34,11 @@ def get_i18n_schema(lang_name, value_name, value_field="marshmallow_utils.fields
31
34
 
32
35
 
33
36
  def MultilingualField( # noqa NOSONAR
34
- *args, lang_name="lang", value_name="value", value_field="marshmallow_utils.fields.SanitizedHTML", **kwargs
37
+ *args,
38
+ lang_name="lang",
39
+ value_name="value",
40
+ value_field="marshmallow_utils.fields.SanitizedHTML",
41
+ **kwargs,
35
42
  ):
36
43
  # TODO: args are not used but oarepo-model-builder-multilingual generates them
37
44
  # should be fixed there and subsequently removed here
@@ -42,7 +49,11 @@ def MultilingualField( # noqa NOSONAR
42
49
 
43
50
 
44
51
  def I18nStrField( # noqa NOSONAR
45
- *args, lang_name="lang", value_name="value", value_field="marshmallow_utils.fields.SanitizedHTML", **kwargs
52
+ *args,
53
+ lang_name="lang",
54
+ value_name="value",
55
+ value_field="marshmallow_utils.fields.SanitizedHTML",
56
+ **kwargs,
46
57
  ):
47
58
  return fields.Nested(
48
59
  get_i18n_schema(lang_name, value_name, value_field),
@@ -1,11 +1,14 @@
1
1
  from functools import lru_cache
2
2
 
3
+ from invenio_base.utils import obj_or_import_string
3
4
  from marshmallow import Schema, fields
4
5
  from marshmallow_utils.fields import SanitizedHTML
5
- from invenio_base.utils import obj_or_import_string
6
+
6
7
 
7
8
  @lru_cache
8
- def get_i18n_ui_schema(lang_name, value_name, value_field="marshmallow_utils.fields.SanitizedHTML"):
9
+ def get_i18n_ui_schema(
10
+ lang_name, value_name, value_field="marshmallow_utils.fields.SanitizedHTML"
11
+ ):
9
12
  value_field_class = obj_or_import_string(value_field)
10
13
  return type(
11
14
  f"I18nUISchema_{lang_name}_{value_name}",
@@ -18,7 +21,11 @@ def get_i18n_ui_schema(lang_name, value_name, value_field="marshmallow_utils.fie
18
21
 
19
22
 
20
23
  def MultilingualUIField( # noqa NOSONAR
21
- *args, lang_name="lang", value_name="value", value_field="marshmallow_utils.fields.SanitizedHTML", **kwargs
24
+ *args,
25
+ lang_name="lang",
26
+ value_name="value",
27
+ value_field="marshmallow_utils.fields.SanitizedHTML",
28
+ **kwargs,
22
29
  ):
23
30
  return fields.List(
24
31
  fields.Nested(get_i18n_ui_schema(lang_name, value_name, value_field)),
@@ -27,7 +34,11 @@ def MultilingualUIField( # noqa NOSONAR
27
34
 
28
35
 
29
36
  def I18nStrUIField( # noqa NOSONAR
30
- *args, lang_name="lang", value_name="value", value_field="marshmallow_utils.fields.SanitizedHTML", **kwargs
37
+ *args,
38
+ lang_name="lang",
39
+ value_name="value",
40
+ value_field="marshmallow_utils.fields.SanitizedHTML",
41
+ **kwargs,
31
42
  ):
32
43
  return fields.Nested(
33
44
  get_i18n_ui_schema(lang_name, value_name, value_field),
@@ -59,9 +70,7 @@ def get_i18n_localized_ui_schema(lang_name, value_name):
59
70
  def MultilingualLocalizedUIField( # noqa NOSONAR
60
71
  *args, lang_name="lang", value_name="value", **kwargs
61
72
  ):
62
- return fields.Nested(
63
- get_i18n_localized_ui_schema(lang_name, value_name), **kwargs
64
- )
73
+ return fields.Nested(get_i18n_localized_ui_schema(lang_name, value_name), **kwargs)
65
74
 
66
75
 
67
76
  def I18nStrLocalizedUIField( # noqa NOSONAR
@@ -189,4 +189,4 @@ class OneOfSchema(Schema):
189
189
  self.load(data, many=many, partial=partial)
190
190
  except ValidationError as ve:
191
191
  return ve.messages
192
- return {}
192
+ return {}
@@ -1,9 +1,11 @@
1
1
  from functools import cached_property
2
2
 
3
3
  import marshmallow as ma
4
- #from marshmallow_oneofschema import OneOfSchema
4
+
5
+ # from marshmallow_oneofschema import OneOfSchema
5
6
  from oarepo_runtime.services.schema.oneofschema import OneOfSchema
6
7
 
8
+
7
9
  class PolymorphicSchema(OneOfSchema):
8
10
  type_field_remove = False
9
11
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.5.38
3
+ Version: 1.5.40
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = oarepo-runtime
3
- version = 1.5.38
3
+ version = 1.5.40
4
4
  description = A set of runtime extensions of Invenio repository
5
5
  authors = Alzbeta Pokorna
6
6
  readme = README.md
@@ -1,6 +0,0 @@
1
- from oarepo_runtime.records.entity_resolvers.proxies import DraftProxy, RecordProxy
2
-
3
- from invenio_records_resources.references import EntityResolver, RecordResolver
4
- from invenio_users_resources.entity_resolvers import UserResolver, GroupResolver
5
-
6
- __all__ = ["DraftProxy", "UserResolver", "GroupResolver", "RecordResolver", "EntityResolver", "RecordProxy"]
File without changes
@@ -1,9 +1,9 @@
1
+ import logging
2
+
1
3
  from invenio_records.systemfields import SystemField
2
4
 
3
5
  from .mapping import MappingSystemFieldMixin
4
6
 
5
- import logging
6
-
7
7
  log = logging.getLogger(__name__)
8
8
 
9
9