X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/d2b0cc75d0835ad5384bec638fea6ea244eadb40..dce4cbe605cb926b5583f7ddd325704b527e7e5c:/src/catalogue/templatetags/catalogue_tags.py diff --git a/src/catalogue/templatetags/catalogue_tags.py b/src/catalogue/templatetags/catalogue_tags.py index d9b0faadc..1a3e0aac9 100644 --- a/src/catalogue/templatetags/catalogue_tags.py +++ b/src/catalogue/templatetags/catalogue_tags.py @@ -436,6 +436,11 @@ def license_icon(license_url): } +@register.simple_tag +def license_locative(license_url, default): + return LICENSES.get(license_url, {}).get('locative', default) + + @register.filter def class_name(obj): return obj.__class__.__name__ @@ -496,3 +501,18 @@ def status(book, user): return 'preview' else: return 'closed' + + +@register.inclusion_tag('catalogue/snippets/content_warning.html') +def content_warning(book): + warnings_def = { + 'wulgaryzmy': _('vulgar language'), + } + warnings = book.get_extra_info_json().get('content_warnings', []) + warnings = sorted( + warnings_def.get(w, w) + for w in warnings + ) + return { + "warnings": warnings + }