Changeset - a0422f0e8433
[Not reviewed]
0 1 0
Christopher Neugebauer - 3 years ago 2017-11-24 23:01:38
chrisjrn@gmail.com
Adds a couple of template tags
1 file changed with 24 insertions and 0 deletions:
0 comments (0 inline, 0 general)
pinaxcon/templatetags/nbpy_tags.py
Show inline comments
 
from registrasion.models import commerce
 
from registrasion.controllers.category import CategoryController
 
from registrasion.controllers.item import ItemController
 
from registrasion.templatetags import registrasion_tags
 

	
 
from decimal import Decimal
 
from django import template
...
 
@@ -42,3 +43,26 @@ def donation_income(context, invoice):
 

	
 
    donation = max(Decimal('0'), (invoice.value - sum(rbi)))
 
    return donation.quantize(Decimal('.01'))
 

	
 

	
 
# TODO: include van/de/van der/de la/etc etc etc
 

	
 
@register.simple_tag
 
def name_split(name):
 

	
 
    tokens = name.split()
 
    even_split = int((len(tokens) + 1) / 2)  # Round up.
 

	
 
    return {
 
        "first" : " ".join(tokens[:even_split]),
 
        "last" : " ".join(tokens[even_split:]),
 
    }
 

	
 

	
 
@register.simple_tag(takes_context=True)
 
def ticket_type(context):
 

	
 
    items = registrasion_tags.items_purchased(context)
 
    for item in items:
 
        if item.product.category.name == "Ticket":
 
            return item.product.name
0 comments (0 inline, 0 general)