Disable borrow button when user reaches max loan limit#12349
Open
ayishaatwork wants to merge 2 commits intointernetarchive:masterfrom
Open
Disable borrow button when user reaches max loan limit#12349ayishaatwork wants to merge 2 commits intointernetarchive:masterfrom
ayishaatwork wants to merge 2 commits intointernetarchive:masterfrom
Conversation
Member
|
What issue does this close? #439? |
mekarpeles
reviewed
Apr 13, 2026
| $ 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 |
Member
There was a problem hiding this comment.
Do not hard code max loans in the code.
This needs to be a variable in openlibrary.yml
openlibrary/conf/openlibrary.yml
Line 4 in 79ff82f
Author
There was a problem hiding this comment.
Hi @mekarpeles, I started implementing the fix and had a quick question about scope.
I noticed that max_loans is currently hardcoded as 5 in borrow.py, and I understand the instruction to move this to openlibrary.yml.
However, in LoanStatus.html, the template doesn’t seem to have access to config, so using config.get('max_loans') there raises a NameError.
Would you prefer that I:
- Keep the template logic simple (still using
5) and only make the backend configurable, or - Pass
max_loans(or a computedhas_reached_loan_limit) from the backend into the template so it stays fully consistent?
mekarpeles
requested changes
Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #
What does this PR achieve?
Disable borrow button when user reaches max loan limit
Technical
LoanStatus.htmlloan_count >= 5, the "Borrow" button is replaced with a disabled buttonuser.get_loan_count()logic (no backend changes)Testing
Testing
Screenshot
Stakeholders
@mekarpeles