1 from django import template
 
   2 from ..models import Offer
 
   3 from ..utils import sanitize_payment_title
 
   5 register = template.Library()
 
   8 @register.inclusion_tag("funding/tags/funding.html", takes_context=True)
 
   9 def funding(context, offer=None, link=False, closeable=False, show_title=True, show_title_calling = True, add_class=""):
 
  10     if offer is None and context.get('funding_no_show_current') is None:
 
  11         offer = Offer.current()
 
  13     elif offer is not None:
 
  14         is_current = offer.is_current()
 
  19     offer_sum = offer.sum()
 
  23         'is_current': is_current,
 
  24         'is_win': offer_sum >= offer.target,
 
  25         'missing': offer.target - offer_sum,
 
  26         'percentage': 100 * offer_sum / offer.target,
 
  28         'closeable': closeable,
 
  29         'show_title': show_title,
 
  30         'show_title_calling': show_title_calling,
 
  31         'add_class': add_class,
 
  35 @register.inclusion_tag("funding/tags/offer_status.html")
 
  36 def offer_status(offer):
 
  41 @register.inclusion_tag("funding/tags/offer_status_more.html")
 
  42 def offer_status_more(offer):
 
  47 register.filter(sanitize_payment_title)