flake8
This commit is contained in:
parent
3562772c13
commit
db332da958
3 changed files with 9 additions and 2 deletions
|
@ -120,8 +120,8 @@ def ProductsForm(category, products):
|
||||||
|
|
||||||
# Each Category.RENDER_TYPE value has a subclass here.
|
# Each Category.RENDER_TYPE value has a subclass here.
|
||||||
RENDER_TYPES = {
|
RENDER_TYPES = {
|
||||||
rego.Category.RENDER_TYPE_QUANTITY : _QuantityBoxProductsForm,
|
rego.Category.RENDER_TYPE_QUANTITY: _QuantityBoxProductsForm,
|
||||||
rego.Category.RENDER_TYPE_RADIO : _RadioButtonProductsForm,
|
rego.Category.RENDER_TYPE_RADIO: _RadioButtonProductsForm,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Produce a subclass of _ProductsForm which we can alter the base_fields on
|
# Produce a subclass of _ProductsForm which we can alter the base_fields on
|
||||||
|
|
|
@ -8,16 +8,19 @@ register = template.Library()
|
||||||
|
|
||||||
ProductAndQuantity = namedtuple("ProductAndQuantity", ["product", "quantity"])
|
ProductAndQuantity = namedtuple("ProductAndQuantity", ["product", "quantity"])
|
||||||
|
|
||||||
|
|
||||||
@register.assignment_tag(takes_context=True)
|
@register.assignment_tag(takes_context=True)
|
||||||
def available_categories(context):
|
def available_categories(context):
|
||||||
''' Returns all of the available product categories '''
|
''' Returns all of the available product categories '''
|
||||||
return rego.Category.objects.all()
|
return rego.Category.objects.all()
|
||||||
|
|
||||||
|
|
||||||
@register.assignment_tag(takes_context=True)
|
@register.assignment_tag(takes_context=True)
|
||||||
def invoices(context):
|
def invoices(context):
|
||||||
''' Returns all of the invoices that this user has. '''
|
''' Returns all of the invoices that this user has. '''
|
||||||
return rego.Invoice.objects.filter(cart__user=context.request.user)
|
return rego.Invoice.objects.filter(cart__user=context.request.user)
|
||||||
|
|
||||||
|
|
||||||
@register.assignment_tag(takes_context=True)
|
@register.assignment_tag(takes_context=True)
|
||||||
def items_pending(context):
|
def items_pending(context):
|
||||||
''' Returns all of the items that this user has in their current cart,
|
''' Returns all of the items that this user has in their current cart,
|
||||||
|
@ -29,6 +32,7 @@ def items_pending(context):
|
||||||
)
|
)
|
||||||
return all_items
|
return all_items
|
||||||
|
|
||||||
|
|
||||||
@register.assignment_tag(takes_context=True)
|
@register.assignment_tag(takes_context=True)
|
||||||
def items_purchased(context):
|
def items_purchased(context):
|
||||||
''' Returns all of the items that this user has purchased '''
|
''' Returns all of the items that this user has purchased '''
|
||||||
|
|
|
@ -185,6 +185,7 @@ def handle_products(request, category, products, prefix):
|
||||||
|
|
||||||
return products_form, discounts, handled
|
return products_form, discounts, handled
|
||||||
|
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def set_quantities_from_products_form(products_form, current_cart):
|
def set_quantities_from_products_form(products_form, current_cart):
|
||||||
for product_id, quantity, field_name in products_form.product_quantities():
|
for product_id, quantity, field_name in products_form.product_quantities():
|
||||||
|
@ -197,6 +198,7 @@ def set_quantities_from_products_form(products_form, current_cart):
|
||||||
raise ValidationError("Cannot add that stuff")
|
raise ValidationError("Cannot add that stuff")
|
||||||
current_cart.end_batch()
|
current_cart.end_batch()
|
||||||
|
|
||||||
|
|
||||||
def handle_voucher(request, prefix):
|
def handle_voucher(request, prefix):
|
||||||
''' Handles a voucher form in the given request. Returns the voucher
|
''' Handles a voucher form in the given request. Returns the voucher
|
||||||
form instance, and whether the voucher code was handled. '''
|
form instance, and whether the voucher code was handled. '''
|
||||||
|
@ -225,6 +227,7 @@ def handle_voucher(request, prefix):
|
||||||
|
|
||||||
return (voucher_form, handled)
|
return (voucher_form, handled)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def checkout(request):
|
def checkout(request):
|
||||||
''' Runs checkout for the current cart of items, ideally generating an
|
''' Runs checkout for the current cart of items, ideally generating an
|
||||||
|
|
Loading…
Reference in a new issue