21f1bb85e141948962cb54eb7e0c0308b725767f
[wolnelektury.git] / src / annoy / templatetags / annoy.py
1 from django import template
2 from ..models import Banner
3 from ..places import PLACES
4
5
6 register = template.Library()
7
8
9 @register.inclusion_tag('annoy/banner.html', takes_context=True)
10 def annoy_banner(context, place):
11     banners = Banner.choice(place, request=context['request'])
12     return {
13         'banner': banners.first(),
14         'closable': PLACES.get(place, False),
15     }
16
17
18 @register.inclusion_tag('annoy/banners.html', takes_context=True)
19 def annoy_banners(context, place):
20     return {
21         'banners': Banner.choice(place, request=context['request']),
22         'closable': PLACES.get(place, False),
23     }