Basic crowdfunding.
[wolnelektury.git] / apps / funding / templatetags / funding_tags.py
diff --git a/apps/funding/templatetags/funding_tags.py b/apps/funding/templatetags/funding_tags.py
new file mode 100755 (executable)
index 0000000..c533672
--- /dev/null
@@ -0,0 +1,17 @@
+from django import template
+from ..models import Offer
+
+register = template.Library()
+
+
+@register.inclusion_tag("funding/tags/funding.html")
+def funding(offer=None, link=False, add_class=""):
+    if offer is None:
+        offer = Offer.current()
+
+    return {
+        'offer': offer,
+        'percentage': 100 * offer.sum() / offer.target,
+        'link': link,
+        'add_class': add_class,
+    }