5331f8c4a5a20bbc35b7ba3c7a8a596cad5b356f
[wolnelektury.git] / apps / funding / templatetags / funding_tags.py
1 from django import template
2 from ..models import Offer
3
4 register = template.Library()
5
6
7 @register.inclusion_tag("funding/tags/funding.html")
8 def funding(offer=None, link=False, add_class=""):
9     if offer is None:
10         offer = Offer.current()
11     if offer is None:
12         return {}
13
14     return {
15         'offer': offer,
16         'is_current': offer.is_current(),
17         'percentage': 100 * offer.sum() / offer.target,
18         'link': link,
19         'add_class': add_class,
20     }
21
22
23 @register.inclusion_tag("funding/tags/offer_detail_head.html")
24 def offer_detail_head(offer):
25     return {
26         'offer': offer,
27         'state': offer.state(),
28     }
29