oarepo-runtime 1.5.24__py3-none-any.whl → 1.5.26__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,15 +11,18 @@ def select_record_for_update(record_cls: Type[Record], persistent_identifier):
11
11
  return record_cls(obj.data, model=obj)
12
12
 
13
13
 
14
- def is_record(record, ctx):
15
- """Shortcut for links to determine if record is a record."""
16
- if not getattr(record, "is_draft", False):
17
- return True
18
- return not record.is_draft
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)
19
22
 
20
23
 
21
24
  def has_draft(record, ctx):
22
- """Shortcut for links to determine if record is a draft or a published one with a draft associated."""
25
+ """Shortcut for links to determine if record is either a draft or a published one with a draft associated."""
23
26
  if getattr(record, "is_draft", False):
24
27
  return True
25
28
  if getattr(record, 'has_draft', False):
@@ -1,8 +1,14 @@
1
1
  from invenio_accounts.models import User
2
+
3
+ from oarepo_runtime.services.generators import RecordOwners
4
+
2
5
  try:
3
6
  from invenio_drafts_resources.services.records.uow import ParentRecordCommitOp
4
7
  except ImportError:
5
- from invenio_records_resources.services.uow import RecordCommitOp as ParentRecordCommitOp
8
+ from invenio_records_resources.services.uow import (
9
+ RecordCommitOp as ParentRecordCommitOp,
10
+ )
11
+
6
12
  from invenio_records_resources.services.records.components import ServiceComponent
7
13
 
8
14
 
@@ -12,16 +18,26 @@ class OwnersComponent(ServiceComponent):
12
18
  self.add_owner(identity, record)
13
19
 
14
20
  def add_owner(self, identity, record, commit=False):
21
+ if not hasattr(identity, "id") or not isinstance(identity.id, int):
22
+ return
23
+
15
24
  owners = getattr(record.parent, "owners", None)
16
25
  if owners is not None:
17
26
  user = User.query.filter_by(id=identity.id).first()
18
27
  record.parent.owners.add(user)
19
28
  if commit:
20
29
  self.uow.register(ParentRecordCommitOp(record.parent))
30
+
21
31
  def update(self, identity, *, record, **kwargs):
22
32
  """Update handler."""
23
33
  self.add_owner(identity, record, commit=True)
24
34
 
25
35
  def update_draft(self, identity, *, record, **kwargs):
26
36
  """Update handler."""
27
- self.add_owner(identity, record, commit=True)
37
+ self.add_owner(identity, record, commit=True)
38
+
39
+ def search_drafts(self, identity, search, params, **kwargs):
40
+ new_term = RecordOwners().query_filter(identity)
41
+ if new_term:
42
+ return search.filter(new_term)
43
+ return search
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.5.24
3
+ Version: 1.5.26
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -42,7 +42,7 @@ oarepo_runtime/datastreams/writers/yaml.py,sha256=XchUJHQ58E2Mfgs8elImXbL38jFtI8
42
42
  oarepo_runtime/i18n/__init__.py,sha256=G4PJ_kQlPDiBW6ntjQZ-O4qHQgkJWAXsNLUuOBcglNM,402
43
43
  oarepo_runtime/info/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
44
  oarepo_runtime/info/views.py,sha256=jtI2JJBdApuT5ZIxU2kskJBz6GpJVTgUGrM8EMNIiAk,11137
45
- oarepo_runtime/records/__init__.py,sha256=3pTrYyhlDJ8-vnOcrEIqZGzBu9T65RuvS26OjJsdJ80,906
45
+ oarepo_runtime/records/__init__.py,sha256=w1vtMmGDpcn9PQ2gbwihrYBZhawhzDWWOpnDdeaOPVo,1038
46
46
  oarepo_runtime/records/dumpers/__init__.py,sha256=OmzNhLdMNKibmCksnj9eTX9xPBG30dziiK3j3bAAp3k,233
47
47
  oarepo_runtime/records/dumpers/edtf_interval.py,sha256=YCShZAoqBQYaxVilEVotS-jXZsxxoXO67yu2urhkaMA,1198
48
48
  oarepo_runtime/records/dumpers/multilingual_dumper.py,sha256=PbNFCLsiH4XV3E1v8xga_fzlcEImHy8OXn_UKh_8VBU,1090
@@ -68,7 +68,7 @@ oarepo_runtime/resources/__init__.py,sha256=v8BGrOTu_FjKzd0eozV7Q4GoGxyfybsL2cI-
68
68
  oarepo_runtime/resources/file_resource.py,sha256=Ta3bFce7l0xwqkkOMOEu9mxbB8BbKj5HUHRHmidhnl8,414
69
69
  oarepo_runtime/resources/localized_ui_json_serializer.py,sha256=4Kle34k-_uu3Y9JJ2vAXcQ9DqYRxXgy-_iZhiFuukmE,1684
70
70
  oarepo_runtime/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
- oarepo_runtime/services/components.py,sha256=Wu-UAQR3AYtne9ZNaHen7hWI9fDdwVEjcHND3_gbeSw,1119
71
+ oarepo_runtime/services/components.py,sha256=9wt9CmoCFA8Utbb8eNA-Mvzo5LCApHT9zHpWIWZNyXY,1506
72
72
  oarepo_runtime/services/generators.py,sha256=V582uA813AIXnFhzqUwakmDgBOI1SQe3XZeJtUXNbwM,872
73
73
  oarepo_runtime/services/results.py,sha256=F3A0U3MRUOYlxNglJPQeGMKdD8QNq1il106jQZ0c9gQ,1499
74
74
  oarepo_runtime/services/search.py,sha256=ywfwGH7oAM44WeOSjlIsY_qoCMZJ1TlTLd_NgE2ow3Y,5296
@@ -114,9 +114,9 @@ oarepo_runtime/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
114
114
  oarepo_runtime/utils/functools.py,sha256=gKS9YZtlIYcDvdNA9cmYO00yjiXBYV1jg8VpcRUyQyg,1324
115
115
  oarepo_runtime/utils/path.py,sha256=V1NVyk3m12_YLbj7QHYvUpE1wScO78bYsX1LOLeXDkI,3108
116
116
  tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
117
- oarepo_runtime-1.5.24.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
118
- oarepo_runtime-1.5.24.dist-info/METADATA,sha256=108JUE4jNX8zWgn68ddFuCEqRS9_-uMSulGE7tEc0KE,4680
119
- oarepo_runtime-1.5.24.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
120
- oarepo_runtime-1.5.24.dist-info/entry_points.txt,sha256=QrlXAKuPDVBinaSh_v3yO9_Nb9ZNmJCJ0VFcCW-z0Jg,327
121
- oarepo_runtime-1.5.24.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
122
- oarepo_runtime-1.5.24.dist-info/RECORD,,
117
+ oarepo_runtime-1.5.26.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
118
+ oarepo_runtime-1.5.26.dist-info/METADATA,sha256=P2aE9x8lip8a2G-51JG4-6fCo7sHsXIxsTQKcDBvqIA,4680
119
+ oarepo_runtime-1.5.26.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
120
+ oarepo_runtime-1.5.26.dist-info/entry_points.txt,sha256=QrlXAKuPDVBinaSh_v3yO9_Nb9ZNmJCJ0VFcCW-z0Jg,327
121
+ oarepo_runtime-1.5.26.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
122
+ oarepo_runtime-1.5.26.dist-info/RECORD,,