X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/032a2b1bdcecc42056de4a0171a55d173e4b765b..e79ef640becb4b59dba11c1dfcce0ea87000919b:/src/catalogue/templatetags/catalogue_tags.py diff --git a/src/catalogue/templatetags/catalogue_tags.py b/src/catalogue/templatetags/catalogue_tags.py index 9f5c04b16..6906f605d 100644 --- a/src/catalogue/templatetags/catalogue_tags.py +++ b/src/catalogue/templatetags/catalogue_tags.py @@ -18,6 +18,7 @@ from ssify import ssi_variable from catalogue.helpers import get_audiobook_tags from catalogue.models import Book, BookMedia, Fragment, Tag, Source from catalogue.constants import LICENSES +from catalogue.utils import is_subscribed from picture.models import Picture register = template.Library() @@ -491,3 +492,13 @@ def strip_tag(html, tag_name): # docelowo może być warto zainstalować BeautifulSoup do takich rzeczy import re return re.sub(r"<.?%s\b[^>]*>" % tag_name, "", html) + + +@register.filter +def status(book, user): + if not book.preview: + return 'open' + elif is_subscribed(user): + return 'preview' + else: + return 'closed'