flake8
This commit is contained in:
parent
a65b7935a9
commit
12e4d0a3cb
6 changed files with 26 additions and 17 deletions
|
@ -4,7 +4,6 @@ import datetime
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import F, Q
|
from django.db.models import F, Q
|
||||||
|
|
|
@ -50,6 +50,7 @@ def items_purchased(context):
|
||||||
out.append(ProductAndQuantity(product, quantity))
|
out.append(ProductAndQuantity(product, quantity))
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def multiply(value, arg):
|
def multiply(value, arg):
|
||||||
''' Multiplies value by arg '''
|
''' Multiplies value by arg '''
|
||||||
|
|
|
@ -382,22 +382,34 @@ class DiscountTestCase(RegistrationCartTestCase):
|
||||||
self.add_discount_prod_1_includes_prod_2(quantity=2)
|
self.add_discount_prod_1_includes_prod_2(quantity=2)
|
||||||
cart = CartController.for_user(self.USER_1)
|
cart = CartController.for_user(self.USER_1)
|
||||||
cart.add_to_cart(self.PROD_1, 1) # Enable the discount
|
cart.add_to_cart(self.PROD_1, 1) # Enable the discount
|
||||||
discounts = discount.available_discounts(self.USER_1, [], [self.PROD_2])
|
discounts = discount.available_discounts(
|
||||||
|
self.USER_1,
|
||||||
|
[],
|
||||||
|
[self.PROD_2],
|
||||||
|
)
|
||||||
self.assertEqual(1, len(discounts))
|
self.assertEqual(1, len(discounts))
|
||||||
|
|
||||||
cart.cart.active = False # Keep discount enabled
|
cart.cart.active = False # Keep discount enabled
|
||||||
cart.cart.save()
|
cart.cart.save()
|
||||||
|
|
||||||
cart = CartController.for_user(self.USER_1)
|
cart = CartController.for_user(self.USER_1)
|
||||||
cart.add_to_cart(self.PROD_2, 2) # The discount will be exhausted
|
cart.add_to_cart(self.PROD_2, 2) # The discount will be exhausted
|
||||||
cart.cart.active = False
|
cart.cart.active = False
|
||||||
cart.cart.save()
|
cart.cart.save()
|
||||||
|
|
||||||
discounts = discount.available_discounts(self.USER_1, [], [self.PROD_2])
|
discounts = discount.available_discounts(
|
||||||
|
self.USER_1,
|
||||||
|
[],
|
||||||
|
[self.PROD_2],
|
||||||
|
)
|
||||||
self.assertEqual(0, len(discounts))
|
self.assertEqual(0, len(discounts))
|
||||||
|
|
||||||
cart.cart.released = True
|
cart.cart.released = True
|
||||||
cart.cart.save()
|
cart.cart.save()
|
||||||
|
|
||||||
discounts = discount.available_discounts(self.USER_1, [], [self.PROD_2])
|
discounts = discount.available_discounts(
|
||||||
|
self.USER_1,
|
||||||
|
[],
|
||||||
|
[self.PROD_2],
|
||||||
|
)
|
||||||
self.assertEqual(1, len(discounts))
|
self.assertEqual(1, len(discounts))
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
import datetime
|
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
from decimal import Decimal
|
|
||||||
from django.core.exceptions import ValidationError
|
|
||||||
|
|
||||||
from registrasion import models as rego
|
|
||||||
from registrasion.controllers.cart import CartController
|
from registrasion.controllers.cart import CartController
|
||||||
from registrasion.controllers.invoice import InvoiceController
|
from registrasion.controllers.invoice import InvoiceController
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import symposion.speakers
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from registrasion import forms
|
from registrasion import forms
|
||||||
|
@ -34,12 +33,14 @@ GuidedRegistrationSection.__new__.__defaults__ = (
|
||||||
(None,) * len(GuidedRegistrationSection._fields)
|
(None,) * len(GuidedRegistrationSection._fields)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_form(name):
|
def get_form(name):
|
||||||
dot = name.rindex(".")
|
dot = name.rindex(".")
|
||||||
mod_name, form_name = name[:dot], name[dot + 1:]
|
mod_name, form_name = name[:dot], name[dot + 1:]
|
||||||
__import__(mod_name)
|
__import__(mod_name)
|
||||||
return getattr(sys.modules[mod_name], form_name)
|
return getattr(sys.modules[mod_name], form_name)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def guided_registration(request, page_id=0):
|
def guided_registration(request, page_id=0):
|
||||||
''' Goes through the registration process in order,
|
''' Goes through the registration process in order,
|
||||||
|
@ -50,7 +51,6 @@ def guided_registration(request, page_id=0):
|
||||||
through each category one by one
|
through each category one by one
|
||||||
'''
|
'''
|
||||||
|
|
||||||
dashboard = redirect("dashboard")
|
|
||||||
next_step = redirect("guided_registration")
|
next_step = redirect("guided_registration")
|
||||||
|
|
||||||
sections = []
|
sections = []
|
||||||
|
@ -71,7 +71,8 @@ def guided_registration(request, page_id=0):
|
||||||
profile = None
|
profile = None
|
||||||
|
|
||||||
if not profile:
|
if not profile:
|
||||||
# TODO: if voucherform is invalid, make sure that profileform does not save
|
# TODO: if voucherform is invalid, make sure
|
||||||
|
# that profileform does not save
|
||||||
voucher_form, voucher_handled = handle_voucher(request, "voucher")
|
voucher_form, voucher_handled = handle_voucher(request, "voucher")
|
||||||
profile_form, profile_handled = handle_profile(request, "profile")
|
profile_form, profile_handled = handle_profile(request, "profile")
|
||||||
|
|
||||||
|
@ -137,7 +138,6 @@ def guided_registration(request, page_id=0):
|
||||||
# This is only saved if we pass each form with no errors.
|
# This is only saved if we pass each form with no errors.
|
||||||
attendee.highest_complete_category = category.id
|
attendee.highest_complete_category = category.id
|
||||||
|
|
||||||
|
|
||||||
if sections and request.method == "POST":
|
if sections and request.method == "POST":
|
||||||
for section in sections:
|
for section in sections:
|
||||||
if section.form.errors:
|
if section.form.errors:
|
||||||
|
@ -150,7 +150,7 @@ def guided_registration(request, page_id=0):
|
||||||
data = {
|
data = {
|
||||||
"current_step": current_step,
|
"current_step": current_step,
|
||||||
"sections": sections,
|
"sections": sections,
|
||||||
"title" : title,
|
"title": title,
|
||||||
"total_steps": 3,
|
"total_steps": 3,
|
||||||
}
|
}
|
||||||
return render(request, "registrasion/guided_registration.html", data)
|
return render(request, "registrasion/guided_registration.html", data)
|
||||||
|
@ -165,6 +165,7 @@ def edit_profile(request):
|
||||||
}
|
}
|
||||||
return render(request, "registrasion/profile_form.html", data)
|
return render(request, "registrasion/profile_form.html", data)
|
||||||
|
|
||||||
|
|
||||||
def handle_profile(request, prefix):
|
def handle_profile(request, prefix):
|
||||||
''' Returns a profile form instance, and a boolean which is true if the
|
''' Returns a profile form instance, and a boolean which is true if the
|
||||||
form was handled. '''
|
form was handled. '''
|
||||||
|
@ -185,7 +186,6 @@ def handle_profile(request, prefix):
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
speaker_name = None
|
speaker_name = None
|
||||||
|
|
||||||
|
|
||||||
name_field = ProfileForm.Meta.model.name_field()
|
name_field = ProfileForm.Meta.model.name_field()
|
||||||
initial = {}
|
initial = {}
|
||||||
if name_field is not None:
|
if name_field is not None:
|
||||||
|
@ -206,6 +206,7 @@ def handle_profile(request, prefix):
|
||||||
|
|
||||||
return form, handled
|
return form, handled
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def product_category(request, category_id):
|
def product_category(request, category_id):
|
||||||
''' Registration selections form for a specific category of items.
|
''' Registration selections form for a specific category of items.
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -20,7 +20,8 @@ setup(
|
||||||
author="Christopher Neugebauer",
|
author="Christopher Neugebauer",
|
||||||
author_email="_@chrisjrn.com",
|
author_email="_@chrisjrn.com",
|
||||||
version=registrasion.__version__,
|
version=registrasion.__version__,
|
||||||
description="A registration app for the Symposion conference management system.",
|
description="A registration app for the Symposion conference management "
|
||||||
|
"system.",
|
||||||
url="http://github.com/chrisjrn/registrasion/",
|
url="http://github.com/chrisjrn/registrasion/",
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
|
|
Loading…
Reference in a new issue