Skip to content

Commit

Permalink
Update path to use /account/loan-history
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbarnes committed Jan 31, 2024
1 parent 8127664 commit 23a7f0d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
37 changes: 19 additions & 18 deletions openlibrary/plugins/upstream/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/templates/account/mybooks.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ <h1 class="details-title">My Stats</h1>
</li>
<li>
<div class="carousel-section-header">
<a data-ol-link-track="MyBooksSidebar|LoanHistory" href="/people/$username/loan-history">
<a data-ol-link-track="MyBooksSidebar|LoanHistory" href="/account/loan-history">
$_('Loan History')
<img class="icon-link__image li-count" src="/static/images/icons/right-chevron.svg">
</a>
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/templates/account/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<a class="li-title-desktop" href="/account/loans" data-ol-link-track="MyBooksSidebar|Loans" $('class=selected' if key == 'loans' else '')>$_('My Loans')</a>
</li>
<li>
<a class="li-title-desktop" data-ol-link-track="MyBooksSidebar|LoanHistory" href="/people/$username/loan-history">$_('Loan History')</a>
<a class="li-title-desktop" data-ol-link-track="MyBooksSidebar|LoanHistory" href="/account/loan-history">$_('Loan History')</a>
</li>
</ul>
$if public or owners_page:
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/templates/books/breadcrumb_select.html
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 23a7f0d

Please sign in to comment.