Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix selected edition availability #6142

Merged
merged 1 commit into from
Feb 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions openlibrary/templates/type/edition/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
$# Book availability of editions injected by bulk get_availability API
$ ebooks_only = query_param('mode') != 'all'
$ editions = work.get_sorted_editions(ebooks_only=ebooks_only)
$ availabilities = {e.availability.get('identifier'): e.availability for e in editions}
$if not editions:
$ ebooks_only = False
$ editions = work.get_sorted_editions()
$ availabilities = {e.availability.get('identifier'): e.availability for e in editions}
$ component_times['get_sorted_editions'] = time() - component_times['get_sorted_editions']

$# This collects which books are previewable in any manner
Expand All @@ -38,7 +38,6 @@
$if page.key.startswith('/books'):
$# We are on an editions page: an edition has been explicitly selected
$ edition = page
$ edition['availability'] = edition.get('ocaid') and availabilities.get(edition['ocaid']) or {}
$elif editions:
$# We're presumably on a work url
$# Set a dummy default editions
Expand All @@ -53,8 +52,9 @@
$ edition = next((e for e in editions if selected_id in provider.get_identifiers(e)), edition)
$else:
$ edition, provider = get_best_edition(editions)
$ edition['availability'] = edition.get('ocaid') and availabilities.get(edition['ocaid']) or {}

$if not edition.get('availability'):
$ edition['availability'] = edition.get('ocaid') and availabilities.get(edition['ocaid']) or {}
$ ocaid = edition.get('ocaid')
$ book_title = edition.get('title', '') or (work.title if work else '')
$ work_title = work.title if work else edition.get('title', '')
Expand Down