Changeset - 9da41c06de54
[Not reviewed]
0 3 0
Christopher Neugebauer - 7 years ago 2017-01-09 07:57:49
chrisjrn@gmail.com
Adds first badge support
3 files changed with 31 insertions and 0 deletions:
0 comments (0 inline, 0 general)
registrasion/templatetags/registrasion_tags.py
Show inline comments
...
 
@@ -95,6 +95,17 @@ def items_purchased(context, category=None):
 
    )
 

	
 

	
 
@register.assignment_tag(takes_context=True)
 
def total_items_purchased(context, category=None):
 
    ''' Returns the number of items purchased for this user (sum of quantities).
 

	
 
    The user will be either `context.user`, and `context.request.user` if
 
    the former is not defined.
 
    '''
 

	
 
    return sum(i.quantity for i in items_purchased(context, category))
 

	
 

	
 
@register.assignment_tag(takes_context=True)
 
def report_as_csv(context, section):
 

	
registrasion/urls.py
Show inline comments
...
 
@@ -5,6 +5,7 @@ from django.conf.urls import url
 

	
 
from .views import (
 
    amend_registration,
 
    badge,
 
    checkout,
 
    credit_note,
 
    edit_profile,
...
 
@@ -22,6 +23,7 @@ from .views import (
 

	
 
public = [
 
    url(r"^amend/([0-9]+)$", amend_registration, name="amend_registration"),
 
    url(r"^badge/([0-9]+)$", badge, name="badge"),
 
    url(r"^category/([0-9]+)$", product_category, name="product_category"),
 
    url(r"^checkout$", checkout, name="checkout"),
 
    url(r"^checkout/([0-9]+)$", checkout, name="checkout"),
registrasion/views.py
Show inline comments
...
 
@@ -968,3 +968,21 @@ def invoice_mailout(request):
 
    }
 

	
 
    return render(request, "registrasion/invoice_mailout.html", data)
 

	
 

	
 
@user_passes_test(_staff_only)
 
def badge(request, user_id):
 
    ''' Renders a single user's badge (SVG). '''
 

	
 
    user_id = int(user_id)
 

	
 
    data = {
 
        "user": User.objects.get(pk=user_id),
 
    }
 

	
 
    print User.objects.get(pk=user_id)
 

	
 
    response = render(request, "registrasion/badge.svg", data)
 
    response["Content-Type"] = "image/svg+xml"
 
    response["Content-Disposition"] = 'inline; filename="badge.svg"'
 
    return response
0 comments (0 inline, 0 general)