Changeset - db332da9584d
[Not reviewed]
0 3 0
Christopher Neugebauer - 8 years ago 2016-03-27 02:12:33
chrisjrn@gmail.com
flake8
2 files changed with 7 insertions and 0 deletions:
0 comments (0 inline, 0 general)
registrasion/templatetags/registrasion_tags.py
Show inline comments
...
 
@@ -7,18 +7,21 @@ from django.db.models import Sum
 
register = template.Library()
 

	
 
ProductAndQuantity = namedtuple("ProductAndQuantity", ["product", "quantity"])
 

	
 

	
 
@register.assignment_tag(takes_context=True)
 
def available_categories(context):
 
    ''' Returns all of the available product categories '''
 
    return rego.Category.objects.all()
 

	
 

	
 
@register.assignment_tag(takes_context=True)
 
def invoices(context):
 
    ''' Returns all of the invoices that this user has. '''
 
    return rego.Invoice.objects.filter(cart__user=context.request.user)
 

	
 

	
 
@register.assignment_tag(takes_context=True)
 
def items_pending(context):
 
    ''' Returns all of the items that this user has in their current cart,
 
    and is awaiting payment. '''
...
 
@@ -28,8 +31,9 @@ def items_pending(context):
 
        cart__active=True,
 
    )
 
    return all_items
 

	
 

	
 
@register.assignment_tag(takes_context=True)
 
def items_purchased(context):
 
    ''' Returns all of the items that this user has purchased '''
 

	
registrasion/views.py
Show inline comments
...
 
@@ -184,8 +184,9 @@ def handle_products(request, category, products, prefix):
 
    discounts = discount.available_discounts(request.user, [], products)
 

	
 
    return products_form, discounts, handled
 

	
 

	
 
@transaction.atomic
 
def set_quantities_from_products_form(products_form, current_cart):
 
    for product_id, quantity, field_name in products_form.product_quantities():
 
        product = rego.Product.objects.get(pk=product_id)
...
 
@@ -196,8 +197,9 @@ def set_quantities_from_products_form(products_form, current_cart):
 
    if products_form.errors:
 
        raise ValidationError("Cannot add that stuff")
 
    current_cart.end_batch()
 

	
 

	
 
def handle_voucher(request, prefix):
 
    ''' Handles a voucher form in the given request. Returns the voucher
 
    form instance, and whether the voucher code was handled. '''
 

	
...
 
@@ -224,8 +226,9 @@ def handle_voucher(request, prefix):
 
        handled = False
 

	
 
    return (voucher_form, handled)
 

	
 

	
 
@login_required
 
def checkout(request):
 
    ''' Runs checkout for the current cart of items, ideally generating an
 
    invoice. '''
0 comments (0 inline, 0 general)