X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/db3bea808bc78fa2d1c6d0be6e0300003f31059c..f5129e7c47fa5fcf0a20f04249b90afcbc54cb9c:/src/annoy/templatetags/annoy.py diff --git a/src/annoy/templatetags/annoy.py b/src/annoy/templatetags/annoy.py new file mode 100644 index 000000000..21f1bb85e --- /dev/null +++ b/src/annoy/templatetags/annoy.py @@ -0,0 +1,23 @@ +from django import template +from ..models import Banner +from ..places import PLACES + + +register = template.Library() + + +@register.inclusion_tag('annoy/banner.html', takes_context=True) +def annoy_banner(context, place): + banners = Banner.choice(place, request=context['request']) + return { + 'banner': banners.first(), + 'closable': PLACES.get(place, False), + } + + +@register.inclusion_tag('annoy/banners.html', takes_context=True) +def annoy_banners(context, place): + return { + 'banners': Banner.choice(place, request=context['request']), + 'closable': PLACES.get(place, False), + }