From 23a7f0d722893d1b3bbadd9ccdf0b8017b8c57df Mon Sep 17 00:00:00 2001 From: Scott Barnes Date: Wed, 31 Jan 2024 09:53:21 -0800 Subject: [PATCH] Update path to use `/account/loan-history` --- openlibrary/plugins/upstream/account.py | 37 ++++++++++--------- openlibrary/templates/account/mybooks.html | 2 +- openlibrary/templates/account/sidebar.html | 2 +- .../templates/books/breadcrumb_select.html | 2 +- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/openlibrary/plugins/upstream/account.py b/openlibrary/plugins/upstream/account.py index fd14d93a389..71e02c5af5e 100644 --- a/openlibrary/plugins/upstream/account.py +++ b/openlibrary/plugins/upstream/account.py @@ -1084,38 +1084,39 @@ def GET(self): class account_loan_history(delegate.page): - path = "/people/([^/]+)/loan-history" + path = "/account/loan-history" @require_login - def GET(self, username): + def GET(self): i = web.input(page=1) page = int(i.page) + user = accounts.get_current_user() + username = user['key'].split('/')[-1] mb = MyBooksTemplate(username, key='loan_history') - if mb.is_my_page: - loan_history_data = get_loan_history_data(page=page, mb=mb) - template = render['account/loan_history']( - docs=loan_history_data['docs'], - current_page=page, - show_next=loan_history_data['show_next'], - ia_base_url=CONFIG_IA_DOMAIN, - ) - return mb.render(header_title=_("Loan History"), template=template) - raise web.seeother(mb.user.key) + loan_history_data = get_loan_history_data(page=page, mb=mb) + template = render['account/loan_history']( + docs=loan_history_data['docs'], + current_page=page, + show_next=loan_history_data['show_next'], + ia_base_url=CONFIG_IA_DOMAIN, + ) + return mb.render(header_title=_("Loan History"), template=template) class account_loan_history_json(delegate.page): encoding = "json" - path = "/people/([^/]+)/loan-history" + path = "/account/loan-history" @require_login - def GET(self, username): + def GET(self): i = web.input(page=1) page = int(i.page) + user = accounts.get_current_user() + username = user['key'].split('/')[-1] mb = MyBooksTemplate(username, key='loan_history') - if mb.is_my_page: - loan_history_data = get_loan_history_data(page=page, mb=mb) - web.header('Content-Type', 'application/json') - return delegate.RawText(json.dumps({"loans_history": loan_history_data})) + loan_history_data = get_loan_history_data(page=page, mb=mb) + web.header('Content-Type', 'application/json') + return delegate.RawText(json.dumps({"loans_history": loan_history_data})) class account_waitlist(delegate.page): diff --git a/openlibrary/templates/account/mybooks.html b/openlibrary/templates/account/mybooks.html index a975cb9166d..2c39a61b13c 100644 --- a/openlibrary/templates/account/mybooks.html +++ b/openlibrary/templates/account/mybooks.html @@ -167,7 +167,7 @@

My Stats

  • - $_('Loan History') + $_('Loan History')
  • $if public or owners_page: diff --git a/openlibrary/templates/books/breadcrumb_select.html b/openlibrary/templates/books/breadcrumb_select.html index bf3bf985988..6d84e03ac77 100644 --- a/openlibrary/templates/books/breadcrumb_select.html +++ b/openlibrary/templates/books/breadcrumb_select.html @@ -13,7 +13,7 @@ $if mb.is_my_page: $ options += [ $ (_("Loans"), "/account/loans"), - $ (_("Loan History"), url_prefix + "/loan-history"), + $ (_("Loan History"), "/account/loan-history"), $ (_("Notes"), url_prefix + "/books/notes"), $ (_("Reviews"), url_prefix + "/books/observations"), $ (_("Imports and Exports"), "/account/import")