invenio-app-ils 4.1.0__py2.py3-none-any.whl → 4.2.0__py2.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.
@@ -7,6 +7,6 @@
7
7
 
8
8
  """invenio-app-ils."""
9
9
 
10
- __version__ = "4.1.0"
10
+ __version__ = "4.2.0"
11
11
 
12
12
  __all__ = ("__version__",)
@@ -44,10 +44,10 @@ from invenio_app_ils.permissions import (
44
44
  PatronOwnerPermission,
45
45
  authenticated_user_permission,
46
46
  backoffice_permission,
47
+ loan_checkout_permission,
47
48
  loan_extend_circulation_permission,
48
49
  patron_owner_permission,
49
50
  superuser_permission,
50
- loan_checkout_permission,
51
51
  )
52
52
 
53
53
  from .api import ILS_CIRCULATION_LOAN_FETCHER, ILS_CIRCULATION_LOAN_MINTER
@@ -12,7 +12,6 @@ from datetime import timedelta
12
12
  import arrow
13
13
  from flask import current_app
14
14
  from invenio_circulation.records.loaders.schemas.json import DateString
15
- from invenio_app_ils.proxies import current_app_ils
16
15
  from marshmallow import (
17
16
  Schema,
18
17
  ValidationError,
@@ -22,6 +21,8 @@ from marshmallow import (
22
21
  validates_schema,
23
22
  )
24
23
 
24
+ from invenio_app_ils.proxies import current_app_ils
25
+
25
26
  from .base import LoanBaseSchemaV1
26
27
 
27
28
 
@@ -10,8 +10,8 @@
10
10
  import jsonresolver
11
11
  from werkzeug.routing import Rule
12
12
 
13
- from invenio_app_ils.proxies import current_app_ils
14
13
  from invenio_app_ils.eitems.api import EItem
14
+ from invenio_app_ils.proxies import current_app_ils
15
15
 
16
16
  # Note: there must be only one resolver per file,
17
17
  # otherwise only the last one is registered
@@ -16,10 +16,10 @@ from invenio_app_ils.records.loaders.schemas.changed_by import (
16
16
  ChangedBySchema,
17
17
  set_changed_by,
18
18
  )
19
+ from invenio_app_ils.records.loaders.schemas.identifiers import IdentifierSchema
19
20
  from invenio_app_ils.records.loaders.schemas.preserve_cover_metadata import (
20
21
  preserve_cover_metadata,
21
22
  )
22
- from invenio_app_ils.records.loaders.schemas.identifiers import IdentifierSchema
23
23
 
24
24
 
25
25
  class AffiliationSchema(Schema):
@@ -11,11 +11,11 @@ from invenio_records_rest.schemas import RecordMetadataSchemaJSONV1
11
11
  from marshmallow import EXCLUDE, Schema, fields, pre_load, validate
12
12
 
13
13
  from invenio_app_ils.eitems.api import EItem
14
- from invenio_app_ils.records.loaders.schemas.identifiers import IdentifierSchema
15
14
  from invenio_app_ils.records.loaders.schemas.changed_by import (
16
15
  ChangedBySchema,
17
16
  set_changed_by,
18
17
  )
18
+ from invenio_app_ils.records.loaders.schemas.identifiers import IdentifierSchema
19
19
 
20
20
 
21
21
  class URLSchema(Schema):
@@ -160,15 +160,27 @@ class Item(IlsRecord):
160
160
  )
161
161
  }
162
162
 
163
+ @classmethod
164
+ def enforce_constraints(cls, data, **kwargs):
165
+ """Enforce constraints.
166
+
167
+ :param data (dict): dict that can be mutated to enforce constraints.
168
+ """
169
+ # barcode is a required field and it should be always uppercase
170
+ data["barcode"] = data["barcode"].upper()
171
+
163
172
  @classmethod
164
173
  def create(cls, data, id_=None, **kwargs):
165
174
  """Create Item record."""
166
175
  cls.build_resolver_fields(data)
167
- return super().create(data, id_=id_, **kwargs)
176
+ cls.enforce_constraints(data, **kwargs)
177
+ created = super().create(data, id_=id_, **kwargs)
178
+ return created
168
179
 
169
180
  def update(self, *args, **kwargs):
170
181
  """Update Item record."""
171
182
  super().update(*args, **kwargs)
183
+ self.enforce_constraints(self)
172
184
  self.build_resolver_fields(self)
173
185
 
174
186
  def delete(self, **kwargs):
@@ -15,8 +15,8 @@ from invenio_app_ils.records.loaders.schemas.changed_by import (
15
15
  ChangedBySchema,
16
16
  set_changed_by,
17
17
  )
18
- from invenio_app_ils.records.loaders.schemas.price import PriceSchema
19
18
  from invenio_app_ils.records.loaders.schemas.identifiers import IdentifierSchema
19
+ from invenio_app_ils.records.loaders.schemas.price import PriceSchema
20
20
 
21
21
 
22
22
  class ISBNSchema(Schema):
@@ -49,7 +49,7 @@ class ItemCSVSerializer(CSVSerializer):
49
49
  pid, record, links_factory=links_factory, **kwargs
50
50
  )
51
51
  filter_circulation(item)
52
- field_cover_metadata(item.get('metadata', {}).get("document", {}))
52
+ field_cover_metadata(item.get("metadata", {}).get("document", {}))
53
53
  return item
54
54
 
55
55
  def transform_search_hit(self, pid, record_hit, links_factory=None, **kwargs):
@@ -58,7 +58,7 @@ class ItemCSVSerializer(CSVSerializer):
58
58
  pid, record_hit, links_factory=links_factory, **kwargs
59
59
  )
60
60
  filter_circulation(hit)
61
- field_cover_metadata(hit.get('metadata', {}).get("document", {}))
61
+ field_cover_metadata(hit.get("metadata", {}).get("document", {}))
62
62
  return hit
63
63
 
64
64
 
@@ -71,7 +71,7 @@ class ItemJSONSerializer(JSONSerializer):
71
71
  pid, record, links_factory=links_factory, **kwargs
72
72
  )
73
73
  filter_circulation(item)
74
- field_cover_metadata(item.get('metadata', {}).get("document", {}))
74
+ field_cover_metadata(item.get("metadata", {}).get("document", {}))
75
75
  return item
76
76
 
77
77
  def transform_search_hit(self, pid, record_hit, links_factory=None, **kwargs):
@@ -80,5 +80,5 @@ class ItemJSONSerializer(JSONSerializer):
80
80
  pid, record_hit, links_factory=links_factory, **kwargs
81
81
  )
82
82
  filter_circulation(hit)
83
- field_cover_metadata(hit.get('metadata', {}).get("document", {}))
83
+ field_cover_metadata(hit.get("metadata", {}).get("document", {}))
84
84
  return hit
@@ -134,25 +134,27 @@ def patron_owner_permission(record):
134
134
  def loan_checkout_permission(*args, **kwargs):
135
135
  """Return permission to allow admins and librarians to checkout and patrons to self-checkout if enabled."""
136
136
  if not has_request_context():
137
- # If from CLI, don't allow self-checkout
137
+ # CLI or Celery task
138
138
  return backoffice_permission()
139
+
139
140
  if current_user.is_anonymous:
140
141
  abort(401)
141
142
 
142
143
  is_admin_or_librarian = backoffice_permission().allows(g.identity)
143
144
  if is_admin_or_librarian:
144
145
  return backoffice_permission()
146
+
147
+ # ensure that only the loan's patron can do operations on this loan
145
148
  if len(args):
146
149
  loan = args[0]
147
150
  else:
148
- loan = kwargs.get("record", {})
149
- is_patron_current_user = current_user.id == int(loan.get("patron_pid"))
150
- if (
151
- current_app.config.get("ILS_SELF_CHECKOUT_ENABLED", False)
152
- and is_patron_current_user
153
- ):
151
+ loan = kwargs["record"]
152
+ is_patron_current_user = current_user.id == int(loan["patron_pid"])
153
+
154
+ if current_app.config["ILS_SELF_CHECKOUT_ENABLED"] and is_patron_current_user:
154
155
  return authenticated_user_permission()
155
- raise LoanCheckoutByPatronForbidden(int(loan.get("patron_pid")), current_user.id)
156
+
157
+ raise LoanCheckoutByPatronForbidden(int(loan["patron_pid"]), current_user.id)
156
158
 
157
159
 
158
160
  class PatronOwnerPermission(Permission):
@@ -163,36 +165,42 @@ class PatronOwnerPermission(Permission):
163
165
  super().__init__(UserNeed(int(record["patron_pid"])), backoffice_access_action)
164
166
 
165
167
 
168
+ _is_authenticated_user = [
169
+ "circulation-loan-request",
170
+ "patron-loans",
171
+ "bulk-loan-extension",
172
+ ]
173
+ _is_backoffice_permission = [
174
+ "circulation-loan-force-checkout",
175
+ "circulation-overdue-loan-notification",
176
+ "circulation-loan-update-dates",
177
+ "relations-create",
178
+ "relations-delete",
179
+ "stats-most-loaned",
180
+ "document-request-actions",
181
+ "bucket-create",
182
+ "ill-brwreq-patron-loan-create",
183
+ "ill-brwreq-patron-loan-extension-accept",
184
+ "ill-brwreq-patron-loan-extension-decline",
185
+ "send-notification-to-patron",
186
+ ]
187
+ _is_patron_owner_permission = [
188
+ "document-request-decline",
189
+ "ill-brwreq-patron-loan-extension-request",
190
+ ]
191
+
192
+
166
193
  def views_permissions_factory(action):
167
194
  """Return ILS views permissions factory."""
168
- is_authenticated_user = [
169
- "circulation-loan-request",
170
- "patron-loans",
171
- "bulk-loan-extension",
172
- ]
173
- is_backoffice_permission = [
174
- "circulation-loan-checkout",
175
- "circulation-loan-force-checkout",
176
- "circulation-overdue-loan-notification",
177
- "circulation-loan-update-dates",
178
- "relations-create",
179
- "relations-delete",
180
- "stats-most-loaned",
181
- "document-request-actions",
182
- "bucket-create",
183
- "ill-brwreq-patron-loan-create",
184
- "ill-brwreq-patron-loan-extension-accept",
185
- "ill-brwreq-patron-loan-extension-decline",
186
- "send-notification-to-patron",
187
- ]
188
- is_patron_owner_permission = [
189
- "document-request-decline",
190
- "ill-brwreq-patron-loan-extension-request",
191
- ]
192
- if action in is_authenticated_user:
195
+ if action in _is_authenticated_user:
193
196
  return authenticated_user_permission()
194
- elif action in is_backoffice_permission:
197
+ elif action in _is_backoffice_permission:
195
198
  return backoffice_permission()
196
- elif action in is_patron_owner_permission:
199
+ elif action in _is_patron_owner_permission:
197
200
  return PatronOwnerPermission
201
+ elif action == "circulation-loan-checkout":
202
+ if current_app.config["ILS_SELF_CHECKOUT_ENABLED"]:
203
+ return authenticated_user_permission()
204
+ else:
205
+ return backoffice_permission()
198
206
  return deny_all()
@@ -20,7 +20,7 @@ from invenio_app_ils.errors import StatsError
20
20
  from invenio_app_ils.permissions import backoffice_permission
21
21
  from invenio_app_ils.records.permissions import RecordPermission
22
22
  from invenio_app_ils.series.api import SERIES_PID_TYPE
23
- from invenio_app_ils.signals import record_viewed, file_downloaded
23
+ from invenio_app_ils.signals import file_downloaded, record_viewed
24
24
 
25
25
 
26
26
  def create_document_stats_blueprint(app):
@@ -425,6 +425,7 @@ class IlsRecordWithRelations(IlsRecord):
425
425
  def relations(self):
426
426
  """Get record relations."""
427
427
  from .retriever import get_relations
428
+
428
429
  return get_relations(self)
429
430
 
430
431
  def clear(self):
@@ -17,7 +17,12 @@ from sqlalchemy import and_, or_
17
17
  from invenio_app_ils.errors import RecordRelationsError
18
18
 
19
19
  ILS_RELATION_TYPE = namedtuple(
20
- "IlsRelationType", RelationType._fields + ("relation_class", "sort_by",)
20
+ "IlsRelationType",
21
+ RelationType._fields
22
+ + (
23
+ "relation_class",
24
+ "sort_by",
25
+ ),
21
26
  )
22
27
 
23
28
  LANGUAGE_RELATION = ILS_RELATION_TYPE(
@@ -21,10 +21,10 @@ from invenio_app_ils.records.loaders.schemas.changed_by import (
21
21
  ChangedBySchema,
22
22
  set_changed_by,
23
23
  )
24
+ from invenio_app_ils.records.loaders.schemas.identifiers import IdentifierSchema
24
25
  from invenio_app_ils.records.loaders.schemas.preserve_cover_metadata import (
25
26
  preserve_cover_metadata,
26
27
  )
27
- from invenio_app_ils.records.loaders.schemas.identifiers import IdentifierSchema
28
28
  from invenio_app_ils.series.api import Series
29
29
 
30
30
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: invenio-app-ils
3
- Version: 4.1.0
3
+ Version: 4.2.0
4
4
  Summary: Invenio Integrated Library System.
5
5
  Home-page: https://github.com/inveniosoftware/invenio-app-ils
6
6
  Author: CERN
@@ -101,6 +101,10 @@ https://invenioils.docs.cern.ch
101
101
  Changes
102
102
  =======
103
103
 
104
+ Version 4.2.0 (released 2024-11-04)
105
+
106
+ - self-checkout: barcode is now always uppercased to make searches case-insensitive
107
+
104
108
  Version 4.1.0 (released 2024-10-21)
105
109
 
106
110
  - search: apply the same search analyzers to the fields that needs to be searchable.
@@ -148,7 +152,7 @@ Version 2.0.0rc9 (released 2024-04-25)
148
152
  Version 2.0.0rc8 (released 2024-04-04)
149
153
 
150
154
  - records_relation: Simplify sorting
151
- - records_relations: Use sort_by paramemter from configs instead
155
+ - records_relations: Use sort_by parameter from configs instead
152
156
  - relations: Add functionality to sort json refs by relation_type
153
157
  - tests: circulation: Add new location for testing closures
154
158
  - circulation: loan_request: Fix dates comparison in get_offset_duration
@@ -1,4 +1,4 @@
1
- invenio_app_ils/__init__.py,sha256=PIW53N5-l4TsnmnQRYUWVI9NhFBFLNMxAuVLWTbiZe4,285
1
+ invenio_app_ils/__init__.py,sha256=BG7JkbyAvqXyUKbb3oLeYr_yMXjp_IyeBWbEWEVKyWY,285
2
2
  invenio_app_ils/cli.py,sha256=wD-SSrkbEhsndI7N9E39p-T1MXj8LR8pvsWFH-JHHVA,57478
3
3
  invenio_app_ils/config.py,sha256=b-3nNceV4s93eS-AS3WEj9eMopROa2hEZ7BI5jDnlAg,40857
4
4
  invenio_app_ils/errors.py,sha256=eXG53KxCnoC0KH9xAjHbu-U2zIsJG28GNPn9PwLTEfk,10486
@@ -7,7 +7,7 @@ invenio_app_ils/facets.py,sha256=x-ID7vL34zqbxJi7VC3EJSee13l_Jk0CfPZN3RHZrM8,420
7
7
  invenio_app_ils/fetchers.py,sha256=GY5A6BXaqMB9HKvJuTcio3JYoF15t6eqMo3yzQKTqac,520
8
8
  invenio_app_ils/indexer.py,sha256=ngXRx2liufDzgsSIoCeusk6q0Y1uskQ3QiVLeAi3KRg,2212
9
9
  invenio_app_ils/minters.py,sha256=8JW-45fL9Oy_13eZjlk8kL_12jJGZK59qbKlCeseQgA,537
10
- invenio_app_ils/permissions.py,sha256=Uj8QUvCNkh7imfZEgZU6VXezrwKQVZBYzipnfZbS58o,6759
10
+ invenio_app_ils/permissions.py,sha256=fW1svDhawp1BfkG_ynvSzJxeN3ea_gPz8-NCr1ICiHc,6859
11
11
  invenio_app_ils/proxies.py,sha256=IGBwXQSOxpXHjD8PWFG1nqUm70xGAgzWT8Y0AKdCGiI,453
12
12
  invenio_app_ils/search_permissions.py,sha256=KxkzgzSz3yabcDMffrsQag4TqZac0w1TBzntb7zjmOQ,5058
13
13
  invenio_app_ils/signals.py,sha256=KaN8yQUVq-2O2IKQQvPLtMjqp1S3AU1LYPlRyw9U8Pg,395
@@ -36,7 +36,7 @@ invenio_app_ils/acquisition/schemas/__init__.py,sha256=HulLvvDz0W5owDGxVLIaastuZ
36
36
  invenio_app_ils/acquisition/schemas/acq_orders/order-v1.0.0.json,sha256=_Kd3oX_7gJJQSqSc2TxQulXletYu0wEeTdQKkXr7kLs,5688
37
37
  invenio_app_ils/circulation/__init__.py,sha256=Gd0KAsGdhPdz0ACEQ9k8xSeOIxZr3xRK_FiE8U3RQWs,248
38
38
  invenio_app_ils/circulation/api.py,sha256=so7YAlzXoO46nMwnXiKoaGgsQHr4OXwOJeUKYe88p0w,11220
39
- invenio_app_ils/circulation/config.py,sha256=VbRT8DDM-8Drtk333CF-7N67AA6YF9oBOEtcB8oxacE,10988
39
+ invenio_app_ils/circulation/config.py,sha256=ZVRFTgn8ZV_ku4nA_GAlyIYc10F-6mpekKiGqF5y_Eo,10988
40
40
  invenio_app_ils/circulation/indexer.py,sha256=T24J5QqcB38LRJgirkAXL2tmFOucYToDRegxgFW96ag,3887
41
41
  invenio_app_ils/circulation/receivers.py,sha256=Ux6KTNbII3DHBvCUS0gxqbi6tNbm76_kbcaHtK0BsB4,2488
42
42
  invenio_app_ils/circulation/search.py,sha256=l9DAr9uoaF_JbfiiXVpAFKW3NLv9bgs7D-uDwtU-fv0,6105
@@ -51,7 +51,7 @@ invenio_app_ils/circulation/loaders/schemas/json/__init__.py,sha256=wsV4twVnMDNW
51
51
  invenio_app_ils/circulation/loaders/schemas/json/base.py,sha256=lkOTJT6pPbukEjwVXEDaFxA7ruslxO3WyQlNuQpiv-U,1444
52
52
  invenio_app_ils/circulation/loaders/schemas/json/bulk_extend.py,sha256=nDqWF2cwiO2GHwPVO6ivPIya6g2AHQ-pZnQoo9e9fQs,638
53
53
  invenio_app_ils/circulation/loaders/schemas/json/loan_checkout.py,sha256=ijIJ-SLgKOutuGrNtWerB9OmIfk7nVPCoFlaocBhUFg,2147
54
- invenio_app_ils/circulation/loaders/schemas/json/loan_request.py,sha256=jlbtdck6FoG7bK5UjLqc-LFka3kUBBURRVcM-ZRyZW4,5920
54
+ invenio_app_ils/circulation/loaders/schemas/json/loan_request.py,sha256=iJVAnyNE1_LfVTuiO_yNtLVMOKHm0OErRbqU4uhczbU,5921
55
55
  invenio_app_ils/circulation/loaders/schemas/json/loan_update_dates.py,sha256=9NtrBJKytly3Acv4wxuqExN0gB9DGnXB8K_27izQkrs,774
56
56
  invenio_app_ils/circulation/notifications/__init__.py,sha256=fG45An4FOBrAIZcWfFtv-3RnyFC4lfHUXWdwy164y_Q,246
57
57
  invenio_app_ils/circulation/notifications/api.py,sha256=UxGle0HgDU5PA7TeS4wVThybrBurOTWGvH_QKSP5Pyg,3429
@@ -122,10 +122,10 @@ invenio_app_ils/documents/jsonresolvers/document_circulation.py,sha256=qwfP9h8R4
122
122
  invenio_app_ils/documents/jsonresolvers/document_eitem.py,sha256=bMLjQlBnsynuKqAdvUmbAe18duI76nqlt-LsGjBu90w,1827
123
123
  invenio_app_ils/documents/jsonresolvers/document_item.py,sha256=gQaXJ2ebEG9uH_sm4iz34M228_tUJEmferpU5u0clZQ,3204
124
124
  invenio_app_ils/documents/jsonresolvers/document_relations.py,sha256=D2VBBK_5hqKwefmoN7lq13oqKcjeRoHohVKQ83HhHkM,1138
125
- invenio_app_ils/documents/jsonresolvers/document_stock.py,sha256=aoSd1ypYt1TgUlc6H6PnTyY9kwm4A5YhqjqVYbwFDcU,1668
125
+ invenio_app_ils/documents/jsonresolvers/document_stock.py,sha256=QQ1WNsHBqzLoxRngK2uyFcqPVCXwLqj4Ayn23dyF7YM,1668
126
126
  invenio_app_ils/documents/loaders/__init__.py,sha256=h_uilf6ka1qi9vwhfDc5SzL1rdWHH2qWCMQrI_LEnoU,414
127
127
  invenio_app_ils/documents/loaders/jsonschemas/__init__.py,sha256=3RyVNmovfMJnmze6_QKSULev8a3yRHUCuO-0y3UFy64,238
128
- invenio_app_ils/documents/loaders/jsonschemas/document.py,sha256=RXemA7NAQvd1qpdGwZcmYoJ3-9G35yxslsL8IRRxb5Q,7577
128
+ invenio_app_ils/documents/loaders/jsonschemas/document.py,sha256=TmnI6QKR1tl-7MAHZGefiuTxCnt81Ikysm4roCsxDvM,7577
129
129
  invenio_app_ils/documents/mappings/__init__.py,sha256=8myTYxQP-EadjBbmAQd3vjZY1-uUGpSQCDv7Sr2cX6A,229
130
130
  invenio_app_ils/documents/mappings/os-v1/__init__.py,sha256=0TRJl_WtkxFUNK3MxyntNg2s-lZILhzB2ZdKMs7qcDI,241
131
131
  invenio_app_ils/documents/mappings/os-v1/documents/document-v1.0.0.json,sha256=o864rRsme4OKA7SwQhpc2ORO5VflH2hpF-58GssfdqA,21646
@@ -148,7 +148,7 @@ invenio_app_ils/eitems/jsonresolvers/eitem_document.py,sha256=dgs0yGqHlfOL00jIJn
148
148
  invenio_app_ils/eitems/jsonresolvers/eitem_files.py,sha256=xCAIL4HGXAGhovxbNLAWz9ra_CsWZ4UpsNzK3VaddKw,1358
149
149
  invenio_app_ils/eitems/loaders/__init__.py,sha256=F3-_mbd-3Pjr8J20gVEDxGs3VE9nMEKChp03LjLi-Uo,401
150
150
  invenio_app_ils/eitems/loaders/jsonschemas/__init__.py,sha256=6bLAkym3u9rgqYTHDHOX3gr5Hh60QNC_YHQMkzIHDgY,236
151
- invenio_app_ils/eitems/loaders/jsonschemas/eitems.py,sha256=nGnT-HOy4veHbg4ffrAWEw5WSKWvured_OfJQEqc2B8,2063
151
+ invenio_app_ils/eitems/loaders/jsonschemas/eitems.py,sha256=KKUe1QvjZ7z6Swtbi2D1vxBiv_55suIXbQYM4E0tJLs,2063
152
152
  invenio_app_ils/eitems/mappings/__init__.py,sha256=PXpNWKcHerg4WIVNBjag0iCPZRQ8pyb3PyxT9zcrnvc,236
153
153
  invenio_app_ils/eitems/mappings/os-v1/__init__.py,sha256=99ifBNKeEw3npzw0AOKCUTP25mcR2Sn1M7Oy8i_Ra_A,239
154
154
  invenio_app_ils/eitems/mappings/os-v1/eitems/eitem-v1.0.0.json,sha256=MBWhA2wJl8t9q12Rc90pwRkTp0Rk8uSPfZWWWDUabDA,2756
@@ -224,7 +224,7 @@ invenio_app_ils/internal_locations/mappings/v7/internal_locations/internal_locat
224
224
  invenio_app_ils/internal_locations/schemas/__init__.py,sha256=gMsPU0b91BaEF60VR_sY6eWLR-BLkkNSldzIdlsyPBA,244
225
225
  invenio_app_ils/internal_locations/schemas/internal_locations/internal_location-v1.0.0.json,sha256=MgGTxIq64uEGryvEyN5EXSORm9lZoE4MHj4ZLaBqr18,1115
226
226
  invenio_app_ils/items/__init__.py,sha256=Jdz0wSG1rNZyyit0VynCMQVDUHo0Vv1S3A2V-PICDfU,226
227
- invenio_app_ils/items/api.py,sha256=xbjklZI1D605VucninFt4AA3bPsKk_md043_Toa__N4,7413
227
+ invenio_app_ils/items/api.py,sha256=olr3T84QU9qVkmXnKgjIg7DIRQGwKRUfPfyaAjW_kwg,7838
228
228
  invenio_app_ils/items/indexer.py,sha256=vWxOnw6o_zH9gDHex4gWrDClP8H2UMyCcrJnxhxjsaU,2022
229
229
  invenio_app_ils/items/search.py,sha256=eyEsQNhMvj-DeYMQRgEsyDn4H0AxqxyMIzPMg6prbIY,2985
230
230
  invenio_app_ils/items/jsonresolvers/__init__.py,sha256=bS7v-bpbyHNrqtY9n5SkDJDcfi9jqOUZYVjjrd9qyy0,244
@@ -233,7 +233,7 @@ invenio_app_ils/items/jsonresolvers/item_internal_location.py,sha256=FKPaEfI8urk
233
233
  invenio_app_ils/items/jsonresolvers/item_loan.py,sha256=RZQP5zvM2lcuAhxQbFlhJJJyxQeNV-ZUE2tMojBApeY,1630
234
234
  invenio_app_ils/items/loaders/__init__.py,sha256=MLPgoiiMW5_7HLacJ4ny3vmmih3qOLA2-5ECPWWwZvg,424
235
235
  invenio_app_ils/items/loaders/jsonschemas/__init__.py,sha256=QjB4GpaGRO8_vUf5F2Igu-VBtCJOrxBBAcyhMYp2uLc,235
236
- invenio_app_ils/items/loaders/jsonschemas/items.py,sha256=Cwi9YmBrYLPMWLpvGelbAhLkfDiWjPbM2JR1QNA_8e0,2073
236
+ invenio_app_ils/items/loaders/jsonschemas/items.py,sha256=vkktlcwZOXhKtZM0ttPUOHFpIJ3eZUIuqg7WeYiZ56k,2073
237
237
  invenio_app_ils/items/mappings/__init__.py,sha256=FHHOdSZAxfKT7lwBTyho9e9H5_MQ5iSJegK9REtcJjY,235
238
238
  invenio_app_ils/items/mappings/os-v1/__init__.py,sha256=d3ZUL6aicw4_MYvaJ3AI5a8vnoEwaSwM5YUDDOgooVg,238
239
239
  invenio_app_ils/items/mappings/os-v1/items/item-v1.0.0.json,sha256=cqSMIOFW7VsuS1FHjsQ0Hy-NuvnYEKhGyaBWM4epP6E,6352
@@ -248,7 +248,7 @@ invenio_app_ils/items/schemas/__init__.py,sha256=oH3ip8OnA1mK1eM3gp8VxEM5LLoSVSW
248
248
  invenio_app_ils/items/schemas/items/item-v1.0.0.json,sha256=kEn3c45Dk_OSJnuRtwJpThUp9WKC_FvBsTr6DcUIqTQ,3960
249
249
  invenio_app_ils/items/schemas/items/item-v2.0.0.json,sha256=kEn3c45Dk_OSJnuRtwJpThUp9WKC_FvBsTr6DcUIqTQ,3960
250
250
  invenio_app_ils/items/serializers/__init__.py,sha256=OxfwU0rGarUnBvznMmiGaJx6uMwX-062pN9RQwR2lhw,914
251
- invenio_app_ils/items/serializers/item.py,sha256=d9TzdYLhpRfp4VyoBdNuYTqQWkshytAk3Q8YUI1E6ms,2967
251
+ invenio_app_ils/items/serializers/item.py,sha256=8qHJp4SFxJj_qM-Pf-Om98KYc5ytweNLJiD94ksGslQ,2967
252
252
  invenio_app_ils/literature/__init__.py,sha256=GELxzVtOq8G2O7Uvs_mLsj0wPnS5l-6ns9mLFDGMEmQ,231
253
253
  invenio_app_ils/literature/api.py,sha256=gbLMK36fN0KXUmygRLadeejPnJ_3CSU_8WFrgxwQ_j4,862
254
254
  invenio_app_ils/literature/covers_builder.py,sha256=_MzoKZik_7UZRKl8szuhcLSD-o8reRSyV8VSbcIbh8g,1285
@@ -323,7 +323,7 @@ invenio_app_ils/records/listeners.py,sha256=6_yZRDh17ujY5zz3gSCArJeId9r8vyo-yadW
323
323
  invenio_app_ils/records/metadata_extensions.py,sha256=Y7knwqFTZ6UQU6-Viuhv22cplGd9VsebXasoDB-o39o,3599
324
324
  invenio_app_ils/records/permissions.py,sha256=_0zd1GCbulcSEGLZ3ZJBaD8Q-TU1r9XLlGLByj-TqCw,3773
325
325
  invenio_app_ils/records/receivers.py,sha256=z9iEd9EMqVw5wS3_pPZTZzeKRyzOguTHqb8FgsKCoD0,493
326
- invenio_app_ils/records/views.py,sha256=Ds4_Fx_YvEVknNoqfpQFyOYf305k6EtkzXLGnojybyg,3410
326
+ invenio_app_ils/records/views.py,sha256=RGdt3ZQOrfvNxuEfv31Dk-udsRG2u_8J73Sb7fiD8m8,3410
327
327
  invenio_app_ils/records/jsonresolvers/__init__.py,sha256=mhHgwyehRSGfoWcfTT9O7F5pCFoS7-yKwJkbFaYRF8Y,249
328
328
  invenio_app_ils/records/jsonresolvers/api.py,sha256=RAM7bqEjqgTn3wx6PlDRY_UEjZknrXiMSB-dMOJwvW0,1183
329
329
  invenio_app_ils/records/loaders/__init__.py,sha256=saCzmtbFLKrgmueTclBSikDwO56XVpHA07PZ_dKu4Bo,817
@@ -336,12 +336,12 @@ invenio_app_ils/records/schemas/__init__.py,sha256=K6l2nVL1zpZM9ZFfZQBgHsjeiSTsk
336
336
  invenio_app_ils/records/schemas/json.py,sha256=r7wShFjJ3FnT_pvunyqfWbgJf9z9iaUV3MhyTEtbEyw,712
337
337
  invenio_app_ils/records/serializers/__init__.py,sha256=pomP0H0b3Zku8lWWcFu86ondB-RJWzO1gDO8mDVEKgo,2230
338
338
  invenio_app_ils/records_relations/__init__.py,sha256=fLycCnrsQv6yVQPARUjHW5QAXcAH7d1dp_dDChQyzFY,238
339
- invenio_app_ils/records_relations/api.py,sha256=2TvOyfwBC5sDVCWX_MUnqlmll53_qXEgSlKb8EQNwKo,16763
339
+ invenio_app_ils/records_relations/api.py,sha256=m2MlN1qS53QtrdqZI8KzRS1bO-0u11QV4z2OcmOFLzI,16764
340
340
  invenio_app_ils/records_relations/indexer.py,sha256=xlNQ6jRKTSrTXX5l0mnbx7kNkfwHeJlw70KsDSqGBeU,2279
341
341
  invenio_app_ils/records_relations/retriever.py,sha256=_PcbdG1IM_hss7xqClvK8Ti-0pB8rBgfOM5GgJvHrNM,8944
342
342
  invenio_app_ils/records_relations/views.py,sha256=-YLUhhSk2oI75RvueAgCxi5L_CafhlsgnNvbePBjobs,14889
343
343
  invenio_app_ils/relations/__init__.py,sha256=K27Ys3WJwwhJp5NnD9RZDbLMIKu_OcOXZWfSTBpcTOY,229
344
- invenio_app_ils/relations/api.py,sha256=2fBGdUJZ9nRnhyr7uy0YlkZJve1jD-qDQMTcJcOEUE8,14074
344
+ invenio_app_ils/relations/api.py,sha256=IDG_6xWv8Mun40csBWuPNXkzRNdaO9wLe1otWquriig,14105
345
345
  invenio_app_ils/relations/nodes.py,sha256=PE_D6gj335EH_G1BWPGEKZOCzrIOII5UpN4a5-MpxcA,376
346
346
  invenio_app_ils/series/__init__.py,sha256=kd4lghqtrIci0-JaTmSIv0kT5DhaydNi5mBh93_x4iw,227
347
347
  invenio_app_ils/series/api.py,sha256=pbFUiOXsR86sN1Shb0eOBIb3EY6zstby4yRXofcQtdQ,3235
@@ -351,7 +351,7 @@ invenio_app_ils/series/jsonresolvers/__init__.py,sha256=KwS1i7XJkydP_YfOMjjvCXbn
351
351
  invenio_app_ils/series/jsonresolvers/series_relations.py,sha256=-QhlHVl93TddK6tsqxyYb3xvp3ISRA9dHa-qz_ZTFW4,1097
352
352
  invenio_app_ils/series/loaders/__init__.py,sha256=2tEAlF_GRq-2-eLXd8e8w4e19iBBZs98E3_nwPQiqlY,404
353
353
  invenio_app_ils/series/loaders/jsonschemas/__init__.py,sha256=h5J1d56DTizrKCfQHHO7d8OH0tno3hb_-dtaKkB63_Y,236
354
- invenio_app_ils/series/loaders/jsonschemas/series.py,sha256=MVOkGUTK02-6lm26sd218W6JfBRS4n939BgImNGeKuI,4110
354
+ invenio_app_ils/series/loaders/jsonschemas/series.py,sha256=K8Z0Bl8wtSxcDCFC1lPGhGPMHdoCPmwvygEDhbaZJeA,4110
355
355
  invenio_app_ils/series/mappings/__init__.py,sha256=A7EmmTOx0yXlMkeimLxvL5xTlwBy3ogbNVRXU8E7bF8,236
356
356
  invenio_app_ils/series/mappings/os-v1/__init__.py,sha256=1Fny1TaeM8uc9Rwvw2bf94RvxEY067R5nP5Lz17UEGs,239
357
357
  invenio_app_ils/series/mappings/os-v1/series/series-v1.0.0.json,sha256=YJLsKB5xjk2IIX8V39tp-1W03r3Vq96c7Ubr_fk1AWA,6919
@@ -500,9 +500,8 @@ tests/api/ils/eitems/test_eitems_permissions.py,sha256=__AlVOpr6Q36xOIiISGTFqAJT
500
500
  tests/api/ils/eitems/test_files.py,sha256=KnzvSYo1HqnFCexXkcKZmmvr_9e4fcABc2D-dE5blK8,4625
501
501
  tests/api/ils/items/__init__.py,sha256=oc7OKnwhkZsi7f8mMAoWhwBFQTHVYeDSAWFVLBXQuEs,229
502
502
  tests/api/ils/items/test_apis.py,sha256=hLD8RCEkGYld7af_JwDFAIL69x8Rin_kElLpqjDn-KE,1366
503
- tests/api/ils/items/test_items_crud.py,sha256=IS1o8Lm3dNKOmt2mrp2bzkTn8KVyTK_WCWEf5ikoCIU,1794
503
+ tests/api/ils/items/test_items_crud.py,sha256=HB3vV5PZWTA1ugumVh7ej9RobRhX1Xf6qIfVRLred7k,3221
504
504
  tests/api/ils/items/test_items_permissions.py,sha256=HE-yYAc6_fza_JXpvTzjcjA9341iAKevJKBoh99jbbw,3757
505
- tests/api/ils/items/test_items_update.py,sha256=_ZZTeh1Y1SZ6zN34O-rVTpEMDyUwqh2LBzbHXsgo69M,1417
506
505
  tests/api/ils/records_relations/__init__.py,sha256=VxNqRmCl2IBDm6PFgG_q_CfFMwFKojB9QtiB-LBONfo,241
507
506
  tests/api/ils/records_relations/helpers.py,sha256=lm2dQdACxYuU2ro-ymA0OtqiKYYldwax8kRmYiqxuWM,3875
508
507
  tests/api/ils/records_relations/test_records_relations_parentchild.py,sha256=vY5gr8L0nrdlvbGKM_wYSD6Vtp4L0QiZoP3YIlwxisA,17969
@@ -528,10 +527,10 @@ tests/templates/notifications/title_body.html,sha256=W-pa6eSm7glK9JEcTVo4G7yC3Q1
528
527
  tests/templates/notifications/title_body_html.html,sha256=wPDP-DpQ0c2AX3oIfLvJLRp7J_rMoesIc9nLx3apkDc,146
529
528
  tests/templates/notifications/title_body_html_ctx.html,sha256=qqfTZ9zKVXFqyXIcqt5BLHEJptRlUDPBPtLxPfTmNzQ,193
530
529
  tests/templates/notifications/title_only.html,sha256=aoZ0veSleRYdKPXWgN6fdXLaz3r-KAPzdfHSuHPR2Uo,45
531
- invenio_app_ils-4.1.0.dist-info/AUTHORS.rst,sha256=BaXCGzdHCmiMOl4qtVlh1qrfy2ROMVOQp6ylzy1m0ww,212
532
- invenio_app_ils-4.1.0.dist-info/LICENSE,sha256=9OdaPOAO1ZOJcRQ8BrGj7QAdaJc8SRSUgBtdom49MrI,1062
533
- invenio_app_ils-4.1.0.dist-info/METADATA,sha256=3KTqFuTubExWO-qq4cNMVUWTCo_sHR3duJ-FcHheYr4,15855
534
- invenio_app_ils-4.1.0.dist-info/WHEEL,sha256=fS9sRbCBHs7VFcwJLnLXN1MZRR0_TVTxvXKzOnaSFs8,110
535
- invenio_app_ils-4.1.0.dist-info/entry_points.txt,sha256=JbIlm87pY7dVL-gLh8Hmfav18psVHXLBmHBzA-fQqlY,7607
536
- invenio_app_ils-4.1.0.dist-info/top_level.txt,sha256=MQTU2NrM0if5YAyIsKmQ0k35skJ3IUyQT7eCD2IWiNQ,22
537
- invenio_app_ils-4.1.0.dist-info/RECORD,,
530
+ invenio_app_ils-4.2.0.dist-info/AUTHORS.rst,sha256=BaXCGzdHCmiMOl4qtVlh1qrfy2ROMVOQp6ylzy1m0ww,212
531
+ invenio_app_ils-4.2.0.dist-info/LICENSE,sha256=9OdaPOAO1ZOJcRQ8BrGj7QAdaJc8SRSUgBtdom49MrI,1062
532
+ invenio_app_ils-4.2.0.dist-info/METADATA,sha256=Y_QgDlw4LmdUhMgdoFh7WwQ34zlpruRFEn1mN9JnSQo,15976
533
+ invenio_app_ils-4.2.0.dist-info/WHEEL,sha256=fS9sRbCBHs7VFcwJLnLXN1MZRR0_TVTxvXKzOnaSFs8,110
534
+ invenio_app_ils-4.2.0.dist-info/entry_points.txt,sha256=JbIlm87pY7dVL-gLh8Hmfav18psVHXLBmHBzA-fQqlY,7607
535
+ invenio_app_ils-4.2.0.dist-info/top_level.txt,sha256=MQTU2NrM0if5YAyIsKmQ0k35skJ3IUyQT7eCD2IWiNQ,22
536
+ invenio_app_ils-4.2.0.dist-info/RECORD,,
@@ -11,11 +11,16 @@ from copy import deepcopy
11
11
 
12
12
  import pytest
13
13
 
14
- from invenio_app_ils.errors import DocumentNotFoundError, InternalLocationNotFoundError
15
- from invenio_app_ils.items.api import Item
14
+ from invenio_app_ils.circulation.search import get_active_loan_by_item_pid
15
+ from invenio_app_ils.errors import (
16
+ DocumentNotFoundError,
17
+ InternalLocationNotFoundError,
18
+ ItemHasPastLoansError,
19
+ )
20
+ from invenio_app_ils.items.api import ITEM_PID_TYPE, Item
16
21
 
17
22
 
18
- def test_item_refs(app, testdata):
23
+ def test_item_create(app, testdata):
19
24
  """Test creation of an item."""
20
25
  item = Item.create(
21
26
  dict(
@@ -23,7 +28,7 @@ def test_item_refs(app, testdata):
23
28
  document_pid="docid-1",
24
29
  internal_location_pid="ilocid-4",
25
30
  created_by=dict(type="script", value="demo"),
26
- barcode="348048",
31
+ barcode="cm-348048",
27
32
  status="CAN_CIRCULATE",
28
33
  circulation_restriction="NO_RESTRICTION",
29
34
  medium="PAPER",
@@ -31,6 +36,7 @@ def test_item_refs(app, testdata):
31
36
  )
32
37
  assert "$schema" in item
33
38
  assert "document" in item and "$ref" in item["document"]
39
+ assert item["barcode"] == "CM-348048"
34
40
  assert "internal_location" in item and "$ref" in item["internal_location"]
35
41
 
36
42
  item = Item.get_record_by_pid("itemid-1")
@@ -39,6 +45,16 @@ def test_item_refs(app, testdata):
39
45
  assert "internal_location" in item and item["internal_location"]["name"]
40
46
 
41
47
 
48
+ def test_item_update(app, db, testdata):
49
+ """Test update of an item."""
50
+ item = Item.get_record_by_pid("itemid-1")
51
+ item.update(dict(barcode="cm-348048"))
52
+ item.commit()
53
+ db.session.commit()
54
+
55
+ assert Item.get_record_by_pid("itemid-1")["barcode"] == "CM-348048"
56
+
57
+
42
58
  def test_item_validation(db, testdata):
43
59
  """Test validation when updating an item."""
44
60
  item_pid = testdata["items"][0]["pid"]
@@ -55,3 +71,29 @@ def test_item_validation(db, testdata):
55
71
  item["internal_location_pid"] = "not_found_pid"
56
72
  with pytest.raises(InternalLocationNotFoundError):
57
73
  item.commit()
74
+
75
+
76
+ def test_item_references(db, testdata):
77
+ """Test references when updating an item."""
78
+
79
+ def get_active_loan_pid_and_item_pid():
80
+ for t in testdata["items"]:
81
+ if t["status"] == "CAN_CIRCULATE":
82
+ item_pid = dict(type=ITEM_PID_TYPE, value=t["pid"])
83
+ active_loan = get_active_loan_by_item_pid(item_pid).execute().hits
84
+ total = active_loan.total.value
85
+ if total > 0:
86
+ return t["pid"], active_loan[0]["pid"]
87
+
88
+ # change document pid while is on loan
89
+ item_pid, loan_pid = get_active_loan_pid_and_item_pid()
90
+ item = Item.get_record_by_pid(item_pid)
91
+ item["document_pid"] = "docid-1"
92
+ with pytest.raises(ItemHasPastLoansError):
93
+ item.commit()
94
+
95
+ # change document to one that does not exist
96
+ item = Item.get_record_by_pid("itemid-1")
97
+ item["document_pid"] = "not_found_doc"
98
+ with pytest.raises(DocumentNotFoundError):
99
+ item.commit()
@@ -1,40 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2018-2020 CERN.
4
- #
5
- # invenio-app-ils is free software; you can redistribute it and/or modify it
6
- # under the terms of the MIT License; see LICENSE file for more details.
7
-
8
- """Test record delete."""
9
-
10
- import pytest
11
-
12
- from invenio_app_ils.circulation.search import get_active_loan_by_item_pid
13
- from invenio_app_ils.errors import DocumentNotFoundError, ItemHasPastLoansError
14
- from invenio_app_ils.items.api import ITEM_PID_TYPE, Item
15
-
16
-
17
- def test_update_item(db, testdata):
18
- """Test update item status."""
19
-
20
- def get_active_loan_pid_and_item_pid():
21
- for t in testdata["items"]:
22
- if t["status"] == "CAN_CIRCULATE":
23
- item_pid = dict(type=ITEM_PID_TYPE, value=t["pid"])
24
- active_loan = get_active_loan_by_item_pid(item_pid).execute().hits
25
- total = active_loan.total.value
26
- if total > 0:
27
- return t["pid"], active_loan[0]["pid"]
28
-
29
- # change document pid while is on loan
30
- item_pid, loan_pid = get_active_loan_pid_and_item_pid()
31
- item = Item.get_record_by_pid(item_pid)
32
- item["document_pid"] = "docid-1"
33
- with pytest.raises(ItemHasPastLoansError):
34
- item.commit()
35
-
36
- # change document to one that does not exist
37
- item = Item.get_record_by_pid("itemid-1")
38
- item["document_pid"] = "not_found_doc"
39
- with pytest.raises(DocumentNotFoundError):
40
- item.commit()