From 02b13ce45ccf277d3cd5d4effc24f7361941a4fb Mon Sep 17 00:00:00 2001 From: ayishaatwork Date: Sat, 11 Apr 2026 19:18:00 +0000 Subject: [PATCH 1/2] Disable borrow button when user reaches max loan limit --- openlibrary/macros/LoanStatus.html | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/openlibrary/macros/LoanStatus.html b/openlibrary/macros/LoanStatus.html index d96a96e7e08..32596bd827e 100644 --- a/openlibrary/macros/LoanStatus.html +++ b/openlibrary/macros/LoanStatus.html @@ -19,6 +19,9 @@ $ waiting_loan = check_loan_status and ocaid and user and user.get_user_waiting_loans(ocaid, use_cache=True) $ waiting_loan_total_time = time() - waiting_loan_start_time $ my_turn_to_borrow = waiting_loan and waiting_loan['status'] == 'available' and waiting_loan['position'] == 1 +$ user = ctx.user if ctx.user else None +$ loan_count = user.get_loan_count() if user else 0 +$ has_reached_loan_limit = loan_count >= 5 $if not waiting_loan: $ book_provider = get_book_provider(doc) @@ -77,7 +80,18 @@ $if secondary_action: $:macros.BookPreview(ocaid, analytics_attr, show_only=False) $if availability.get("available_to_borrow") or availability.get("available_to_browse"): - $:macros.ReadButton(ocaid, analytics_attr, borrow=True, listen=listen, edition_key=edition_key) + $if has_reached_loan_limit: +
+ +
+ $else: + $:macros.ReadButton(ocaid, analytics_attr, borrow=True, listen=listen, edition_key=edition_key) $elif availability.get('available_to_waitlist'): $if waiting_loan: $if secondary_action: @@ -159,4 +173,4 @@

get_waiting_loan_for(ocaid) took $("%.2f" % waiting_loan_total_time) seconds

$# detect-missing-i18n-skip-line

get_loan_for(ocaid) took $("%.2f" % get_loan_for_total_time) seconds

$# detect-missing-i18n-skip-line

LoanStatus took $("%.2f" % loanstatus_end_time) seconds

$# detect-missing-i18n-skip-line -

$availability

+

$availability

\ No newline at end of file From be1abe86d3acdcd5baa610a757ad516cb7f746b0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 11 Apr 2026 19:59:49 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- openlibrary/i18n/messages.pot | 8 ++++++++ openlibrary/macros/LoanStatus.html | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/openlibrary/i18n/messages.pot b/openlibrary/i18n/messages.pot index 48d1e599580..3e6059e28f6 100644 --- a/openlibrary/i18n/messages.pot +++ b/openlibrary/i18n/messages.pot @@ -371,6 +371,14 @@ msgstr "" msgid "Read" msgstr "" +#: LoanStatus.html +msgid "You have reached the maximum number of borrowed books." +msgstr "" + +#: LoanStatus.html +msgid "Loan Limit Reached" +msgstr "" + #: LoanStatus.html msgid "You are next on the waiting list" msgstr "" diff --git a/openlibrary/macros/LoanStatus.html b/openlibrary/macros/LoanStatus.html index 32596bd827e..f9b31be808a 100644 --- a/openlibrary/macros/LoanStatus.html +++ b/openlibrary/macros/LoanStatus.html @@ -173,4 +173,4 @@

get_waiting_loan_for(ocaid) took $("%.2f" % waiting_loan_total_time) seconds

$# detect-missing-i18n-skip-line

get_loan_for(ocaid) took $("%.2f" % get_loan_for_total_time) seconds

$# detect-missing-i18n-skip-line

LoanStatus took $("%.2f" % loanstatus_end_time) seconds

$# detect-missing-i18n-skip-line -

$availability

\ No newline at end of file +

$availability