From ce9ed3dca045346ec0a73817da93dfdc5ed0735d Mon Sep 17 00:00:00 2001 From: "Michael E. Karpeles (Mek)" Date: Sat, 12 Feb 2022 22:55:26 +0000 Subject: [PATCH] fix selected edition availability --- openlibrary/templates/type/edition/view.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlibrary/templates/type/edition/view.html b/openlibrary/templates/type/edition/view.html index ca3024b8126..a781a941b35 100644 --- a/openlibrary/templates/type/edition/view.html +++ b/openlibrary/templates/type/edition/view.html @@ -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 @@ -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 @@ -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', '')