X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/1249091e84840ca27aa6047db36c8e899328f15c..aa5bd5145e825b6b828ef0e4781e75c10dcace71:/src/catalogue/templatetags/catalogue_tags.py diff --git a/src/catalogue/templatetags/catalogue_tags.py b/src/catalogue/templatetags/catalogue_tags.py index 8124b349c..cddd273e1 100644 --- a/src/catalogue/templatetags/catalogue_tags.py +++ b/src/catalogue/templatetags/catalogue_tags.py @@ -424,6 +424,9 @@ def download_audio(book, daisy=True, mp3=True): if daisy and book.has_media('daisy'): for dsy in book.get_media('daisy'): links.append("%s" % (dsy.file.url, BookMedia.formats['daisy'].name)) + if daisy and book.has_media('audio.epub'): + for dsy in book.get_media('audio.epub'): + links.append("%s" % (dsy.file.url, BookMedia.formats['audio.epub'].name)) return mark_safe("".join(links)) @@ -509,7 +512,7 @@ def strip_tag(html, tag_name): def status(book, user): if not book.preview: return 'open' - elif Membership.is_active_for(user): + elif book.is_accessible_to(user): return 'preview' else: return 'closed' @@ -528,3 +531,12 @@ def content_warning(book): return { "warnings": warnings } + + +@register.inclusion_tag('catalogue/preview_ad.html', takes_context=True) +def preview_ad(context): + book = Book.objects.filter(preview=True).first() + return { + 'accessible': book.is_accessible_to(context['request'].user), + 'book': book, + }