1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django import template
6 from ..models import Offer
7 from ..utils import sanitize_payment_title
9 register = template.Library()
12 @register.inclusion_tag("funding/tags/funding.html", takes_context=True)
13 def funding(context, offer=None, link=False, closeable=False, show_title=True, show_title_calling=True, add_class=""):
14 if offer is None and context.get('funding_no_show_current') is None:
15 offer = Offer.current()
17 elif offer is not None:
18 is_current = offer.is_current()
23 offer_sum = offer.sum()
27 'is_current': is_current,
28 'is_win': offer_sum >= offer.target,
29 'missing': offer.target - offer_sum,
30 'percentage': 100 * offer_sum / offer.target,
32 'closeable': closeable,
33 'show_title': show_title,
34 'show_title_calling': show_title_calling,
35 'add_class': add_class,
39 @register.inclusion_tag("funding/tags/offer_status.html")
40 def offer_status(offer):
45 @register.inclusion_tag("funding/tags/offer_status_more.html")
46 def offer_status_more(offer):
51 register.filter(sanitize_payment_title)