File tree Expand file tree Collapse file tree 4 files changed +8
-14
lines changed
Expand file tree Collapse file tree 4 files changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -272,7 +272,9 @@ class NoAvailableCopiesWhenReserved(CannotLoan):
272272
273273 @property
274274 def base (self ) -> ProblemDetail :
275- return NO_COPIES_WHEN_RESERVED
275+ return CHECKOUT_FAILED .detailed (
276+ detail = "No copies available to check out, you are still next in line."
277+ )
276278
277279
278280class NoAvailableCopies (CannotLoan ):
Original file line number Diff line number Diff line change @@ -463,15 +463,14 @@ def _checkout(
463463
464464 # No best available licenses were found in the first place or, for some reason, there's no status.
465465 if license_ is None or loan_status is None :
466- # It could be that we have a hold which means we thought the book was available, but it wasn't.
467- # We raise a NoAvailableCopies() and have the handler handle the patron's hold position.
468- self .log .info (f"No license or status was none. Raising NoAvailableCopies." )
469466 licensepool .update_availability_from_licenses ()
467+ # If we have a hold, it means we thought the book was available, but it wasn't.
468+ # So we need to update availability and the hold queue.
470469 if hold :
471470 # The license should be available at most by the default loan period in E-Kirjasto.
472471 hold .end = utc_now () + datetime .timedelta (days = default_loan_period )
473- # Instantly recalculate the holds queue so that this hold goes to position 1 and not 0.
474472 self ._recalculate_holds_in_license_pool (licensepool )
473+ raise NoAvailableCopiesWhenReserved ()
475474 raise NoAvailableCopies ()
476475
477476 if not loan_status .active :
Original file line number Diff line number Diff line change 5656 _ ("All licenses for this book are loaned out." ),
5757)
5858
59- # E-kirjasto
60- NO_COPIES_WHEN_RESERVED = pd (
61- "http://librarysimplified.org/terms/problem/cannot-issue-loan" ,
62- 502 ,
63- _ ("No available license." ),
64- _ ("All copies of this book are loaned out after all. You are next in line." ),
65- )
66-
6759NO_ACCEPTABLE_FORMAT = pd (
6860 "http://librarysimplified.org/terms/problem/no-acceptable-format" ,
6961 400 ,
Original file line number Diff line number Diff line change 2121 CannotReturn ,
2222 CurrentlyAvailable ,
2323 NoAvailableCopies ,
24+ NoAvailableCopiesWhenReserved ,
2425 NoLicenses ,
2526 NotCheckedOut ,
2627 NotOnHold ,
@@ -706,7 +707,7 @@ def test_checkout_ready_hold_no_available_copies(
706707 content = opds2_with_odl_api_fixture .files .sample_text ("unavailable.json" ),
707708 )
708709 with opds2_with_odl_api_fixture .mock_http .patch ():
709- with pytest .raises (NoAvailableCopies ):
710+ with pytest .raises (NoAvailableCopiesWhenReserved ):
710711 opds2_with_odl_api_fixture .api_checkout ()
711712 assert db .session .query (Hold ).count () == 2
712713
You can’t perform that action at this time.
0 commit comments