Adds first badge support
This commit is contained in:
parent
cbb04cbdf4
commit
9da41c06de
3 changed files with 31 additions and 0 deletions
|
@ -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):
|
||||
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue