Changeset - 8d66ed57150d
[Not reviewed]
0 6 0
Christopher Neugebauer - 8 years ago 2016-03-25 03:51:39
chrisjrn@gmail.com
Fix flake8 warnings
6 files changed with 22 insertions and 14 deletions:
0 comments (0 inline, 0 general)
registrasion/forms.py
Show inline comments
...
 
@@ -43,7 +43,6 @@ def CategoryForm(category):
 
                if not prod.can_add_with_enabling_conditions(user, 0):
 
                    self.disable_product(product)
 

	
 

	
 
    products = rego.Product.objects.filter(category=category).order_by("order")
 
    for product in products:
 

	
registrasion/templatetags/registrasion_tags.py
Show inline comments
...
 
@@ -4,6 +4,7 @@ from django import template
 

	
 
register = template.Library()
 

	
 

	
 
@register.assignment_tag(takes_context=True)
 
def available_categories(context):
 
    ''' Returns all of the available product categories '''
registrasion/tests/test_discount.py
Show inline comments
...
 
@@ -208,7 +208,7 @@ class DiscountTestCase(RegistrationCartTestCase):
 
        # in the same way
 
        for user in (self.USER_1, self.USER_2):
 
            cart = CartController.for_user(user)
 
            cart.add_to_cart(self.PROD_1, 1) # Enable the discount
 
            cart.add_to_cart(self.PROD_1, 1)  # Enable the discount
 
            cart.add_to_cart(self.PROD_3, 1)
 

	
 
            discount_items = list(cart.cart.discountitem_set.all())
registrasion/tests/test_voucher.py
Show inline comments
...
 
@@ -95,13 +95,13 @@ class VoucherTestCases(RegistrationCartTestCase):
 
        self.assertEqual(1, len(current_cart.cart.discountitem_set.all()))
 

	
 
    def test_voucher_codes_unique(self):
 
        voucher1 = self.new_voucher(code="VOUCHER")
 
        self.new_voucher(code="VOUCHER")
 
        with self.assertRaises(IntegrityError):
 
            voucher2 = self.new_voucher(code="VOUCHER")
 
            self.new_voucher(code="VOUCHER")
 

	
 
    def test_multiple_vouchers_work(self):
 
        voucher1 = self.new_voucher(code="VOUCHER1")
 
        voucher2 = self.new_voucher(code="VOUCHER2")
 
        self.new_voucher(code="VOUCHER1")
 
        self.new_voucher(code="VOUCHER2")
 

	
 
    def test_vouchers_case_insensitive(self):
 
        voucher = self.new_voucher(code="VOUCHeR")
registrasion/urls.py
Show inline comments
...
 
@@ -8,5 +8,6 @@ urlpatterns = patterns(
 
    url(r"^invoice/([0-9]+)/pay$", "pay_invoice", name="pay_invoice"),
 
    url(r"^profile$", "edit_profile", name="profile"),
 
    url(r"^register$", "guided_registration", name="guided_registration"),
 
    url(r"^register/([0-9]+)$", "guided_registration", name="guided_registration"),
 
    url(r"^register/([0-9]+)$", "guided_registration",
 
        name="guided_registration"),
 
)
registrasion/views.py
Show inline comments
...
 
@@ -2,7 +2,6 @@ from registrasion import forms
 
from registrasion import models as rego
 
from registrasion.controllers.cart import CartController
 
from registrasion.controllers.invoice import InvoiceController
 
from registrasion.controllers.product import ProductController
 

	
 
from django.contrib.auth.decorators import login_required
 
from django.core.exceptions import ObjectDoesNotExist
...
 
@@ -83,6 +82,7 @@ def edit_profile(request):
 
    }
 
    return render(request, "profile_form.html", data)
 

	
 

	
 
@login_required
 
def product_category(request, category_id):
 
    ''' Registration selections form for a specific category of items.
...
 
@@ -103,11 +103,17 @@ def product_category(request, category_id):
 
    products = products.order_by("order")
 

	
 
    if request.method == "POST":
 
        cat_form = CategoryForm(request.POST, request.FILES, prefix=PRODUCTS_FORM_PREFIX)
 
        cat_form = CategoryForm(
 
            request.POST,
 
            request.FILES,
 
            prefix=PRODUCTS_FORM_PREFIX)
 
        cat_form.disable_products_for_user(request.user)
 
        voucher_form = forms.VoucherForm(request.POST, prefix=VOUCHERS_FORM_PREFIX)
 
        voucher_form = forms.VoucherForm(
 
            request.POST,
 
            prefix=VOUCHERS_FORM_PREFIX)
 

	
 
        if voucher_form.is_valid() and voucher_form.cleaned_data["voucher"].strip():
 
        if (voucher_form.is_valid() and
 
                voucher_form.cleaned_data["voucher"].strip()):
 
            # Apply voucher
 
            # leave
 
            voucher = voucher_form.cleaned_data["voucher"]
...
 
@@ -119,7 +125,7 @@ def product_category(request, category_id):
 
        elif cat_form.is_valid():
 
            try:
 
                handle_valid_cat_form(cat_form, current_cart)
 
            except ValidationError as ve:
 
            except ValidationError:
 
                pass
 

	
 
            # If category is required, the user must have at least one
...
 
@@ -153,7 +159,6 @@ def product_category(request, category_id):
 
        quantities = []
 
        for product in products:
 
            # Only add items that are enabled.
 
            prod = ProductController(product)
 
            try:
 
                quantity = items.get(product=product).quantity
 
            except ObjectDoesNotExist:
...
 
@@ -166,7 +171,6 @@ def product_category(request, category_id):
 

	
 
        voucher_form = forms.VoucherForm(prefix=VOUCHERS_FORM_PREFIX)
 

	
 

	
 
    data = {
 
        "category": category,
 
        "form": cat_form,
...
 
@@ -175,6 +179,7 @@ def product_category(request, category_id):
 

	
 
    return render(request, "product_category.html", data)
 

	
 

	
 
@transaction.atomic
 
def handle_valid_cat_form(cat_form, current_cart):
 
    for product_id, quantity, field_name in cat_form.product_quantities():
...
 
@@ -187,6 +192,7 @@ def handle_valid_cat_form(cat_form, current_cart):
 
        raise ValidationError("Cannot add that stuff")
 
    current_cart.end_batch()
 

	
 

	
 
@login_required
 
def checkout(request):
 
    ''' Runs checkout for the current cart of items, ideally generating an
...
 
@@ -212,6 +218,7 @@ def invoice(request, invoice_id):
 

	
 
    return render(request, "invoice.html", data)
 

	
 

	
 
@login_required
 
def pay_invoice(request, invoice_id):
 
    ''' Marks the invoice with the given invoice id as paid.
0 comments (0 inline, 0 general)