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
...
 
@@ -86,23 +86,34 @@ def items_pending(context):
 
def items_purchased(context, category=None):
 
    ''' Returns the items purchased for this user.
 

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

	
 
    return ItemController(user_for_context(context)).items_purchased(
 
        category=category
 
    )
 

	
 

	
 
@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):
 

	
 
    old_query = context.request.META["QUERY_STRING"]
 
    query = dict([("section", section), ("content_type", "text/csv")])
 
    querystring = urlencode(query)
 

	
 
    if old_query:
 
        querystring = old_query + "&" + querystring
 

	
 
    return context.request.path + "?" + querystring
registrasion/urls.py
Show inline comments
 
from reporting import views as rv
 

	
 
from django.conf.urls import include
 
from django.conf.urls import url
 

	
 
from .views import (
 
    amend_registration,
 
    badge,
 
    checkout,
 
    credit_note,
 
    edit_profile,
 
    extend_reservation,
 
    guided_registration,
 
    invoice,
 
    invoice_access,
 
    invoice_mailout,
 
    manual_payment,
 
    product_category,
 
    refund,
 
    review,
 
)
 

	
 

	
 
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"),
 
    url(r"^credit_note/([0-9]+)$", credit_note, name="credit_note"),
 
    url(r"^extend/([0-9]+)$", extend_reservation, name="extend_reservation"),
 
    url(r"^invoice/([0-9]+)$", invoice, name="invoice"),
 
    url(r"^invoice/([0-9]+)/([A-Z0-9]+)$", invoice, name="invoice"),
 
    url(r"^invoice/([0-9]+)/manual_payment$",
 
        manual_payment, name="manual_payment"),
 
    url(r"^invoice/([0-9]+)/refund$",
 
        refund, name="refund"),
 
    url(r"^invoice_access/([A-Z0-9]+)$", invoice_access,
registrasion/views.py
Show inline comments
...
 
@@ -959,12 +959,30 @@ def invoice_mailout(request):
 

	
 
        if form.cleaned_data["action"] == forms.InvoiceEmailForm.ACTION_SEND:
 
            # Send e-mails *ONLY* if we're sending.
 
            send_mass_mail(emails)
 
            messages.info(request, "The e-mails have been sent.")
 

	
 
    data = {
 
        "form": form,
 
        "emails": emails,
 
    }
 

	
 
    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)