Changes to the wording, small cosmetic changes
[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", takes_context=True)
8 def funding(context, offer=None, link=False, closeable=False, show_title=True, show_title_calling = True, add_class=""):
9     if offer is None and context.get('funding_no_show_current') is None:
10         offer = Offer.current()
11     if offer is None:
12         return {}
13
14     offer_sum = offer.sum()
15     return {
16         'offer': offer,
17         'sum': offer_sum,
18         'is_current': offer.is_current(),
19         'is_win': offer_sum >= offer.target,
20         'missing': offer.target - offer_sum,
21         'percentage': 100 * offer_sum / offer.target,
22         'link': link,
23         'closeable': closeable,
24         'show_title': show_title,
25         'show_title_calling': show_title_calling,
26         'add_class': add_class,
27     }
28
29
30 @register.inclusion_tag("funding/tags/offer_status.html")
31 def offer_status(offer):
32     return {
33         'offer': offer,
34     }
35     
36 @register.inclusion_tag("funding/tags/offer_status_more.html")
37 def offer_status_more(offer):
38     return {
39         'offer': offer,
40     }
41
42