Huge batch of pep8 fixes

This commit is contained in:
Sachi King 2017-04-22 18:39:07 +10:00
parent bcb63fd1cd
commit 17693754de
21 changed files with 105 additions and 111 deletions

View file

@ -82,6 +82,7 @@ class IncludedProductDiscountAdmin(admin.ModelAdmin, EffectsDisplayMixin):
DiscountForCategoryInline, DiscountForCategoryInline,
] ]
@admin.register(conditions.SpeakerDiscount) @admin.register(conditions.SpeakerDiscount)
class SpeakerDiscountAdmin(admin.ModelAdmin, EffectsDisplayMixin): class SpeakerDiscountAdmin(admin.ModelAdmin, EffectsDisplayMixin):

View file

@ -165,7 +165,6 @@ class CartController(object):
product_quantities = list(product_quantities) product_quantities = list(product_quantities)
# n.b need to add have the existing items first so that the new # n.b need to add have the existing items first so that the new
# items override the old ones. # items override the old ones.
all_product_quantities = dict(itertools.chain( all_product_quantities = dict(itertools.chain(

View file

@ -40,7 +40,8 @@ class CreditNoteController(ForId, object):
paid. paid.
''' '''
from invoice import InvoiceController # Circular imports bleh. # Circular Import
from registrasion.controllers.invoice import InvoiceController
inv = InvoiceController(invoice) inv = InvoiceController(invoice)
inv.validate_allowed_to_pay() inv.validate_allowed_to_pay()
@ -64,7 +65,8 @@ class CreditNoteController(ForId, object):
a cancellation fee. Must be 0 <= percentage <= 100. a cancellation fee. Must be 0 <= percentage <= 100.
''' '''
from invoice import InvoiceController # Circular imports bleh. # Circular Import
from registrasion.controllers.invoice import InvoiceController
assert(percentage >= 0 and percentage <= 100) assert(percentage >= 0 and percentage <= 100)

View file

@ -2,7 +2,6 @@ from decimal import Decimal
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import transaction from django.db import transaction
from django.db.models import Sum
from django.utils import timezone from django.utils import timezone
from registrasion.contrib.mail import send_email from registrasion.contrib.mail import send_email

View file

@ -3,7 +3,6 @@ from registrasion.models import commerce
from registrasion.models import inventory from registrasion.models import inventory
from django import forms from django import forms
from django.core.exceptions import ValidationError
from django.db.models import Q from django.db.models import Q
@ -31,10 +30,11 @@ class ApplyCreditNoteForm(forms.Form):
}) })
key = lambda inv: (0 - (inv["user_id"] == self.user.id), inv["id"]) key = lambda inv: (0 - (inv["user_id"] == self.user.id), inv["id"]) # noqa
invoices_annotated.sort(key=key) invoices_annotated.sort(key=key)
template = "Invoice %(id)d - user: %(user_email)s (%(user_id)d) - $%(value)d" template = ('Invoice %(id)d - user: %(user_email)s (%(user_id)d) '
'- $%(value)d')
return [ return [
(invoice["id"], template % invoice) (invoice["id"], template % invoice)
for invoice in invoices_annotated for invoice in invoices_annotated
@ -57,6 +57,7 @@ class CancellationFeeForm(forms.Form):
max_value=100, max_value=100,
) )
class ManualCreditNoteRefundForm(forms.ModelForm): class ManualCreditNoteRefundForm(forms.ModelForm):
class Meta: class Meta:
@ -407,6 +408,7 @@ def staff_products_form_factory(user):
return StaffProductsForm return StaffProductsForm
def staff_products_formset_factory(user): def staff_products_formset_factory(user):
''' Creates a formset of StaffProductsForm for the given user. ''' ''' Creates a formset of StaffProductsForm for the given user. '''
form_type = staff_products_form_factory(user) form_type = staff_products_form_factory(user)
@ -446,7 +448,7 @@ class InvoicesWithProductAndStatusForm(forms.Form):
qs = qs.order_by("id") qs = qs.order_by("id")
self.fields['invoice'].queryset = qs self.fields['invoice'].queryset = qs
#self.fields['invoice'].initial = [i.id for i in qs] # UNDO THIS LATER # self.fields['invoice'].initial = [i.id for i in qs] # UNDO THIS LATER
class InvoiceEmailForm(InvoicesWithProductAndStatusForm): class InvoiceEmailForm(InvoicesWithProductAndStatusForm):

View file

@ -63,7 +63,6 @@ class GroupByForm(forms.Form):
) )
def model_fields_form_factory(model): def model_fields_form_factory(model):
''' Creates a form for specifying fields from a model to display. ''' ''' Creates a form for specifying fields from a model to display. '''

View file

@ -1,5 +1,4 @@
import csv import csv
import registrasion.reporting.forms
from django.contrib.auth.decorators import user_passes_test from django.contrib.auth.decorators import user_passes_test
from django.shortcuts import render from django.shortcuts import render

View file

@ -163,7 +163,7 @@ def sales_payment_summary():
data.append([ data.append([
"Credit notes - (claimed credit notes + unclaimed credit notes)", "Credit notes - (claimed credit notes + unclaimed credit notes)",
all_credit_notes - claimed_credit_notes - all_credit_notes - claimed_credit_notes -
refunded_credit_notes - unclaimed_credit_notes, refunded_credit_notes - unclaimed_credit_notes
]) ])
return ListReport("Sales and Payments Summary", headings, data) return ListReport("Sales and Payments Summary", headings, data)
@ -291,8 +291,8 @@ def discount_status(request, form):
items = group_by_cart_status( items = group_by_cart_status(
items, items,
["discount",], ["discount"],
["discount", "discount__description",], ["discount", "discount__description"],
) )
headings = [ headings = [
@ -362,6 +362,7 @@ def paid_invoices_by_date(request, form):
data, data,
) )
@report_view("Credit notes") @report_view("Credit notes")
def credit_notes(request, form): def credit_notes(request, form):
''' Shows all of the credit notes in the system. ''' ''' Shows all of the credit notes in the system. '''
@ -375,7 +376,9 @@ def credit_notes(request, form):
return QuerysetReport( return QuerysetReport(
"Credit Notes", "Credit Notes",
["id", "invoice__user__attendee__attendeeprofilebase__invoice_recipient", "status", "value"], # NOQA ["id",
"invoice__user__attendee__attendeeprofilebase__invoice_recipient",
"status", "value"],
notes, notes,
headings=["id", "Owner", "Status", "Value"], headings=["id", "Owner", "Status", "Value"],
link_view=views.credit_note, link_view=views.credit_note,
@ -383,7 +386,7 @@ def credit_notes(request, form):
@report_view("Invoices") @report_view("Invoices")
def invoices(request,form): def invoices(request, form):
''' Shows all of the invoices in the system. ''' ''' Shows all of the invoices in the system. '''
invoices = commerce.Invoice.objects.all().order_by("status", "id") invoices = commerce.Invoice.objects.all().order_by("status", "id")
@ -562,6 +565,7 @@ def attendee_list(request):
ProfileForm = forms.model_fields_form_factory(AttendeeProfile) ProfileForm = forms.model_fields_form_factory(AttendeeProfile)
@report_view( @report_view(
"Attendees By Product/Category", "Attendees By Product/Category",
form_type=forms.mix_form( form_type=forms.mix_form(
@ -580,7 +584,8 @@ def attendee_data(request, form, user_id=None):
output = [] output = []
by_category = form.cleaned_data["group_by"] == forms.GroupByForm.GROUP_BY_CATEGORY by_category = (
form.cleaned_data["group_by"] == forms.GroupByForm.GROUP_BY_CATEGORY)
products = form.cleaned_data["product"] products = form.cleaned_data["product"]
categories = form.cleaned_data["category"] categories = form.cleaned_data["category"]
@ -597,7 +602,8 @@ def attendee_data(request, form, user_id=None):
# Add invoice nag link # Add invoice nag link
links = [] links = []
invoice_mailout = reverse(views.invoice_mailout, args=[]) + "?" + request.META["QUERY_STRING"] invoice_mailout = reverse(views.invoice_mailout, args=[])
invoice_mailout += "?" + request.META["QUERY_STRING"]
links += [ links += [
(invoice_mailout + "&status=1", "Send invoice reminders",), (invoice_mailout + "&status=1", "Send invoice reminders",),
(invoice_mailout + "&status=2", "Send mail for paid invoices",), (invoice_mailout + "&status=2", "Send mail for paid invoices",),
@ -621,7 +627,7 @@ def attendee_data(request, form, user_id=None):
by_user[profile.attendee.user] = profile by_user[profile.attendee.user] = profile
cart = "attendee__user__cart" cart = "attendee__user__cart"
cart_status = cart + "__status" cart_status = cart + "__status" # noqa
product = cart + "__productitem__product" product = cart + "__productitem__product"
product_name = product + "__name" product_name = product + "__name"
category = product + "__category" category = product + "__category"
@ -631,12 +637,12 @@ def attendee_data(request, form, user_id=None):
grouping_fields = (category, category_name) grouping_fields = (category, category_name)
order_by = (category, ) order_by = (category, )
first_column = "Category" first_column = "Category"
group_name = lambda i: "%s" % (i[category_name], ) group_name = lambda i: "%s" % (i[category_name], ) # noqa
else: else:
grouping_fields = (product, product_name, category_name) grouping_fields = (product, product_name, category_name)
order_by = (category, ) order_by = (category, )
first_column = "Product" first_column = "Product"
group_name = lambda i: "%s - %s" % (i[category_name], i[product_name]) group_name = lambda i: "%s - %s" % (i[category_name], i[product_name]) # noqa
# Group the responses per-field. # Group the responses per-field.
for field in fields: for field in fields:
@ -663,7 +669,7 @@ def attendee_data(request, form, user_id=None):
def display_field(value): def display_field(value):
return value return value
status_count = lambda status: Case(When( status_count = lambda status: Case(When( # noqa
attendee__user__cart__status=status, attendee__user__cart__status=status,
then=Value(1), then=Value(1),
), ),
@ -710,7 +716,8 @@ def attendee_data(request, form, user_id=None):
else: else:
return attr return attr
headings = ["User ID", "Name", "Email", "Product", "Item Status"] + field_names headings = ["User ID", "Name", "Email", "Product", "Item Status"]
headings.extend(field_names)
data = [] data = []
for item in items: for item in items:
profile = by_user[item.cart.user] profile = by_user[item.cart.user]
@ -726,7 +733,8 @@ def attendee_data(request, form, user_id=None):
data.append(line) data.append(line)
output.append(AttendeeListReport( output.append(AttendeeListReport(
"Attendees by item with profile data", headings, data, link_view=attendee "Attendees by item with profile data", headings, data,
link_view=attendee
)) ))
return output return output
@ -763,7 +771,7 @@ def speaker_registrations(request, form):
return QuerysetReport( return QuerysetReport(
"Speaker Registration Status", "Speaker Registration Status",
["id", "speaker_profile__name", "email", "paid_carts",], ["id", "speaker_profile__name", "email", "paid_carts"],
users, users,
link_view=attendee, link_view=attendee,
) )
@ -776,7 +784,10 @@ def speaker_registrations(request, form):
forms.ProductAndCategoryForm, forms.ProductAndCategoryForm,
) )
def manifest(request, form): def manifest(request, form):
''' Produces the registration manifest for people with the given product type.''' '''
Produces the registration manifest for people with the given product
type.
'''
products = form.cleaned_data["product"] products = form.cleaned_data["product"]
categories = form.cleaned_data["category"] categories = form.cleaned_data["category"]
@ -835,9 +846,9 @@ def manifest(request, form):
headings = ["User ID", "Name", "Paid", "Unpaid", "Refunded"] headings = ["User ID", "Name", "Paid", "Unpaid", "Refunded"]
def format_items(item_list): def format_items(item_list):
strings = [ strings = []
"%d x %s" % (item.quantity, str(item.product)) for item in item_list for item in item_list:
] strings.append('%d x %s' % (item.quantity, str(item.product)))
return ", \n".join(strings) return ", \n".join(strings)
output = [] output = []
@ -853,4 +864,4 @@ def manifest(request, form):
return ListReport("Manifest", headings, output) return ListReport("Manifest", headings, output)
#attendeeprofilebase.attendee_name() # attendeeprofilebase.attendee_name()

View file

@ -1,6 +1,6 @@
import pytz import pytz
from test_cart import RegistrationCartTestCase from registrasion.tests.test_cart import RegistrationCartTestCase
from registrasion.controllers.batch import BatchController from registrasion.controllers.batch import BatchController

View file

@ -15,8 +15,8 @@ from registrasion.models import people
from registrasion.controllers.batch import BatchController from registrasion.controllers.batch import BatchController
from registrasion.controllers.product import ProductController from registrasion.controllers.product import ProductController
from controller_helpers import TestingCartController from registrasion.tests.controller_helpers import TestingCartController
from patches import MixInPatches from registrasion.tests.patches import MixInPatches
UTC = pytz.timezone('UTC') UTC = pytz.timezone('UTC')
@ -67,7 +67,7 @@ class RegistrationCartTestCase(MixInPatches, TestCase):
cls.RESERVATION = datetime.timedelta(hours=1) cls.RESERVATION = datetime.timedelta(hours=1)
cls.categories = [] cls.categories = []
for i in xrange(2): for i in range(2):
cat = inventory.Category.objects.create( cat = inventory.Category.objects.create(
name="Category " + str(i + 1), name="Category " + str(i + 1),
description="This is a test category", description="This is a test category",
@ -81,7 +81,7 @@ class RegistrationCartTestCase(MixInPatches, TestCase):
cls.CAT_2 = cls.categories[1] cls.CAT_2 = cls.categories[1]
cls.products = [] cls.products = []
for i in xrange(4): for i in range(4):
prod = inventory.Product.objects.create( prod = inventory.Product.objects.create(
name="Product " + str(i + 1), name="Product " + str(i + 1),
description="This is a test product.", description="This is a test product.",
@ -460,7 +460,6 @@ class BasicCartTests(RegistrationCartTestCase):
cart.cart.refresh_from_db() cart.cart.refresh_from_db()
self.assertEqual(cart.cart.reservation_duration, new_res) self.assertEqual(cart.cart.reservation_duration, new_res)
def test_reservation_duration_removals(self): def test_reservation_duration_removals(self):
''' Reservation duration should update with removals ''' Reservation duration should update with removals
''' '''

View file

@ -3,8 +3,8 @@ import pytz
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from controller_helpers import TestingCartController from registrasion.tests.controller_helpers import TestingCartController
from test_cart import RegistrationCartTestCase from registrasion.tests.test_cart import RegistrationCartTestCase
from registrasion.controllers.discount import DiscountController from registrasion.controllers.discount import DiscountController
from registrasion.controllers.product import ProductController from registrasion.controllers.product import ProductController
@ -47,36 +47,36 @@ class CeilingsTestCases(RegistrationCartTestCase):
def test_add_to_cart_ceiling_date_range(self): def test_add_to_cart_ceiling_date_range(self):
self.make_ceiling( self.make_ceiling(
"date range ceiling", "date range ceiling",
start_time=datetime.datetime(2015, 01, 01, tzinfo=UTC), start_time=datetime.datetime(2015, 1, 1, tzinfo=UTC),
end_time=datetime.datetime(2015, 02, 01, tzinfo=UTC)) end_time=datetime.datetime(2015, 2, 1, tzinfo=UTC))
current_cart = TestingCartController.for_user(self.USER_1) current_cart = TestingCartController.for_user(self.USER_1)
# User should not be able to add whilst we're before start_time # User should not be able to add whilst we're before start_time
self.set_time(datetime.datetime(2014, 01, 01, tzinfo=UTC)) self.set_time(datetime.datetime(2014, 1, 1, tzinfo=UTC))
with self.assertRaises(ValidationError): with self.assertRaises(ValidationError):
current_cart.add_to_cart(self.PROD_1, 1) current_cart.add_to_cart(self.PROD_1, 1)
# User should be able to add whilst we're during date range # User should be able to add whilst we're during date range
# On edge of start # On edge of start
self.set_time(datetime.datetime(2015, 01, 01, tzinfo=UTC)) self.set_time(datetime.datetime(2015, 1, 1, tzinfo=UTC))
current_cart.add_to_cart(self.PROD_1, 1) current_cart.add_to_cart(self.PROD_1, 1)
# In middle # In middle
self.set_time(datetime.datetime(2015, 01, 15, tzinfo=UTC)) self.set_time(datetime.datetime(2015, 1, 15, tzinfo=UTC))
current_cart.add_to_cart(self.PROD_1, 1) current_cart.add_to_cart(self.PROD_1, 1)
# On edge of end # On edge of end
self.set_time(datetime.datetime(2015, 02, 01, tzinfo=UTC)) self.set_time(datetime.datetime(2015, 2, 1, tzinfo=UTC))
current_cart.add_to_cart(self.PROD_1, 1) current_cart.add_to_cart(self.PROD_1, 1)
# User should not be able to add whilst we're after date range # User should not be able to add whilst we're after date range
self.set_time(datetime.datetime(2014, 01, 01, minute=01, tzinfo=UTC)) self.set_time(datetime.datetime(2014, 1, 1, minute=1, tzinfo=UTC))
with self.assertRaises(ValidationError): with self.assertRaises(ValidationError):
current_cart.add_to_cart(self.PROD_1, 1) current_cart.add_to_cart(self.PROD_1, 1)
def test_add_to_cart_ceiling_limit_reserved_carts(self): def test_add_to_cart_ceiling_limit_reserved_carts(self):
self.make_ceiling("Limit ceiling", limit=1) self.make_ceiling("Limit ceiling", limit=1)
self.set_time(datetime.datetime(2015, 01, 01, tzinfo=UTC)) self.set_time(datetime.datetime(2015, 1, 1, tzinfo=UTC))
first_cart = TestingCartController.for_user(self.USER_1) first_cart = TestingCartController.for_user(self.USER_1)
second_cart = TestingCartController.for_user(self.USER_2) second_cart = TestingCartController.for_user(self.USER_2)
@ -113,7 +113,7 @@ class CeilingsTestCases(RegistrationCartTestCase):
self.__validation_test() self.__validation_test()
def __validation_test(self): def __validation_test(self):
self.set_time(datetime.datetime(2015, 01, 01, tzinfo=UTC)) self.set_time(datetime.datetime(2015, 1, 1, tzinfo=UTC))
first_cart = TestingCartController.for_user(self.USER_1) first_cart = TestingCartController.for_user(self.USER_1)
second_cart = TestingCartController.for_user(self.USER_2) second_cart = TestingCartController.for_user(self.USER_2)
@ -144,7 +144,7 @@ class CeilingsTestCases(RegistrationCartTestCase):
"Multi-product limit discount ceiling", "Multi-product limit discount ceiling",
limit=2, limit=2,
) )
for i in xrange(2): for i in range(2):
cart = TestingCartController.for_user(self.USER_1) cart = TestingCartController.for_user(self.USER_1)
cart.add_to_cart(self.PROD_1, 1) cart.add_to_cart(self.PROD_1, 1)
cart.next_cart() cart.next_cart()
@ -162,7 +162,7 @@ class CeilingsTestCases(RegistrationCartTestCase):
# after second. # after second.
self.make_ceiling("Multi-product limit ceiling", limit=2) self.make_ceiling("Multi-product limit ceiling", limit=2)
for i in xrange(2): for i in range(2):
cart = TestingCartController.for_user(self.USER_1) cart = TestingCartController.for_user(self.USER_1)
cart.add_to_cart(self.PROD_1, 1) cart.add_to_cart(self.PROD_1, 1)
cart.next_cart() cart.next_cart()

View file

@ -1,18 +1,15 @@
import datetime import datetime
import pytz import pytz
from decimal import Decimal
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from registrasion.models import commerce from registrasion.models import commerce
from registrasion.models import conditions from registrasion.tests.controller_helpers import TestingCartController
from registrasion.models import inventory from registrasion.tests.controller_helpers import TestingInvoiceController
from controller_helpers import TestingCartController from registrasion.tests.test_helpers import TestHelperMixin
from controller_helpers import TestingCreditNoteController
from controller_helpers import TestingInvoiceController from registrasion.tests.test_cart import RegistrationCartTestCase
from test_helpers import TestHelperMixin
from test_cart import RegistrationCartTestCase
UTC = pytz.timezone('UTC') UTC = pytz.timezone('UTC')
@ -142,7 +139,7 @@ class CreditNoteTestCase(TestHelperMixin, RegistrationCartTestCase):
invoice.refund() invoice.refund()
# There should be one credit note generated out of the invoice. # There should be one credit note generated out of the invoice.
cn = self._credit_note_for_invoice(invoice.invoice) cn = self._credit_note_for_invoice(invoice.invoice) # noqa
self.assertEquals(1, commerce.CreditNote.unclaimed().count()) self.assertEquals(1, commerce.CreditNote.unclaimed().count())
@ -324,7 +321,7 @@ class CreditNoteTestCase(TestHelperMixin, RegistrationCartTestCase):
# will be invalidated. A new invoice should be generated. # will be invalidated. A new invoice should be generated.
cart.add_to_cart(self.PROD_1, 1) cart.add_to_cart(self.PROD_1, 1)
invoice = TestingInvoiceController.for_id(invoice.invoice.id) invoice = TestingInvoiceController.for_id(invoice.invoice.id)
invoice2 = TestingInvoiceController.for_cart(cart.cart) invoice2 = TestingInvoiceController.for_cart(cart.cart) # noqa
cn2 = self._credit_note_for_invoice(invoice.invoice) cn2 = self._credit_note_for_invoice(invoice.invoice)
invoice._refresh() invoice._refresh()
@ -387,7 +384,6 @@ class CreditNoteTestCase(TestHelperMixin, RegistrationCartTestCase):
notes_value = self._generate_multiple_credit_notes() notes_value = self._generate_multiple_credit_notes()
invoice = self._manual_invoice(notes_value - 1) invoice = self._manual_invoice(notes_value - 1)
self.assertEqual(notes_value - 1, invoice.invoice.total_payments()) self.assertEqual(notes_value - 1, invoice.invoice.total_payments())
self.assertTrue(invoice.invoice.is_paid) self.assertTrue(invoice.invoice.is_paid)
@ -403,14 +399,14 @@ class CreditNoteTestCase(TestHelperMixin, RegistrationCartTestCase):
''' Tests that excess credit notes are untouched if they're not needed ''' Tests that excess credit notes are untouched if they're not needed
''' '''
notes_value = self._generate_multiple_credit_notes() notes_value = self._generate_multiple_credit_notes() # noqa
notes_old = commerce.CreditNote.unclaimed().filter( notes_old = commerce.CreditNote.unclaimed().filter(
invoice__user=self.USER_1 invoice__user=self.USER_1
) )
# Create a manual invoice whose value is smaller than any of the # Create a manual invoice whose value is smaller than any of the
# credit notes we created # credit notes we created
invoice = self._manual_invoice(1) invoice = self._manual_invoice(1) # noqa
notes_new = commerce.CreditNote.unclaimed().filter( notes_new = commerce.CreditNote.unclaimed().filter(
invoice__user=self.USER_1 invoice__user=self.USER_1
) )
@ -422,7 +418,7 @@ class CreditNoteTestCase(TestHelperMixin, RegistrationCartTestCase):
def test_credit_notes_are_not_applied_if_user_has_multiple_invoices(self): def test_credit_notes_are_not_applied_if_user_has_multiple_invoices(self):
# Have an invoice pending with no credit notes; no payment will be made # Have an invoice pending with no credit notes; no payment will be made
invoice1 = self._invoice_containing_prod_1(1) invoice1 = self._invoice_containing_prod_1(1) # noqa
# Create some credit notes. # Create some credit notes.
self._generate_multiple_credit_notes() self._generate_multiple_credit_notes()
@ -435,7 +431,7 @@ class CreditNoteTestCase(TestHelperMixin, RegistrationCartTestCase):
def test_credit_notes_are_applied_even_if_some_notes_are_claimed(self): def test_credit_notes_are_applied_even_if_some_notes_are_claimed(self):
for i in xrange(10): for i in range(10):
# Generate credit note # Generate credit note
invoice1 = self._manual_invoice(1) invoice1 = self._manual_invoice(1)
invoice1.pay("Pay", invoice1.invoice.value) invoice1.pay("Pay", invoice1.invoice.value)
@ -467,5 +463,5 @@ class CreditNoteTestCase(TestHelperMixin, RegistrationCartTestCase):
def test_cancellation_fee_is_applied_when_another_invoice_is_unpaid(self): def test_cancellation_fee_is_applied_when_another_invoice_is_unpaid(self):
extra_invoice = self._manual_invoice(23) extra_invoice = self._manual_invoice(23) # noqa
self.test_cancellation_fee_is_applied() self.test_cancellation_fee_is_applied()

View file

@ -5,9 +5,9 @@ from decimal import Decimal
from registrasion.models import commerce from registrasion.models import commerce
from registrasion.models import conditions from registrasion.models import conditions
from registrasion.controllers.discount import DiscountController from registrasion.controllers.discount import DiscountController
from controller_helpers import TestingCartController from registrasion.tests.controller_helpers import TestingCartController
from test_cart import RegistrationCartTestCase from registrasion.tests.test_cart import RegistrationCartTestCase
UTC = pytz.timezone('UTC') UTC = pytz.timezone('UTC')

View file

@ -5,11 +5,11 @@ from django.core.exceptions import ValidationError
from registrasion.models import commerce from registrasion.models import commerce
from registrasion.models import conditions from registrasion.models import conditions
from registrasion.controllers.category import CategoryController from registrasion.controllers.category import CategoryController
from controller_helpers import TestingCartController from registrasion.tests.controller_helpers import TestingCartController
from controller_helpers import TestingInvoiceController from registrasion.tests.controller_helpers import TestingInvoiceController
from registrasion.controllers.product import ProductController from registrasion.controllers.product import ProductController
from test_cart import RegistrationCartTestCase from registrasion.tests.test_cart import RegistrationCartTestCase
UTC = pytz.timezone('UTC') UTC = pytz.timezone('UTC')

View file

@ -1,16 +1,11 @@
import pytz import pytz
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from django.core.exceptions import ValidationError
from registrasion.models import commerce
from registrasion.models import conditions from registrasion.models import conditions
from registrasion.controllers.category import CategoryController
from controller_helpers import TestingCartController
from controller_helpers import TestingInvoiceController
from registrasion.controllers.product import ProductController from registrasion.controllers.product import ProductController
from test_cart import RegistrationCartTestCase from registrasion.tests.test_cart import RegistrationCartTestCase
UTC = pytz.timezone('UTC') UTC = pytz.timezone('UTC')

View file

@ -2,9 +2,10 @@ import datetime
from registrasion.models import commerce from registrasion.models import commerce
from controller_helpers import TestingCartController from registrasion.tests.controller_helpers import TestingCartController
from controller_helpers import TestingCreditNoteController from registrasion.tests.controller_helpers import TestingCreditNoteController
from controller_helpers import TestingInvoiceController from registrasion.tests.controller_helpers import TestingInvoiceController
class TestHelperMixin(object): class TestHelperMixin(object):

View file

@ -7,12 +7,11 @@ from django.core.exceptions import ValidationError
from registrasion.models import commerce from registrasion.models import commerce
from registrasion.models import conditions from registrasion.models import conditions
from registrasion.models import inventory from registrasion.models import inventory
from controller_helpers import TestingCartController from registrasion.tests.controller_helpers import TestingCartController
from controller_helpers import TestingCreditNoteController from registrasion.tests.controller_helpers import TestingInvoiceController
from controller_helpers import TestingInvoiceController from registrasion.tests.test_helpers import TestHelperMixin
from test_helpers import TestHelperMixin
from test_cart import RegistrationCartTestCase from registrasion.tests.test_cart import RegistrationCartTestCase
UTC = pytz.timezone('UTC') UTC = pytz.timezone('UTC')
@ -67,7 +66,7 @@ class InvoiceTestCase(TestHelperMixin, RegistrationCartTestCase):
def test_create_invoice_fails_if_cart_invalid(self): def test_create_invoice_fails_if_cart_invalid(self):
self.make_ceiling("Limit ceiling", limit=1) self.make_ceiling("Limit ceiling", limit=1)
self.set_time(datetime.datetime(2015, 01, 01, tzinfo=UTC)) self.set_time(datetime.datetime(2015, 1, 1, tzinfo=UTC))
current_cart = TestingCartController.for_user(self.USER_1) current_cart = TestingCartController.for_user(self.USER_1)
current_cart.add_to_cart(self.PROD_1, 1) current_cart.add_to_cart(self.PROD_1, 1)
@ -166,7 +165,6 @@ class InvoiceTestCase(TestHelperMixin, RegistrationCartTestCase):
current_cart.add_to_cart(self.PROD_1, 1) current_cart.add_to_cart(self.PROD_1, 1)
return TestingInvoiceController.for_cart(current_cart.cart) return TestingInvoiceController.for_cart(current_cart.cart)
def test_zero_value_invoice_is_automatically_paid(self): def test_zero_value_invoice_is_automatically_paid(self):
invoice_1 = self._make_zero_value_invoice() invoice_1 = self._make_zero_value_invoice()
self.assertTrue(invoice_1.invoice.is_paid) self.assertTrue(invoice_1.invoice.is_paid)
@ -220,7 +218,7 @@ class InvoiceTestCase(TestHelperMixin, RegistrationCartTestCase):
# generate an invoice # generate an invoice
self.add_timedelta(self.RESERVATION * 2) self.add_timedelta(self.RESERVATION * 2)
cart2.add_to_cart(self.PROD_2, 1) cart2.add_to_cart(self.PROD_2, 1)
inv2 = TestingInvoiceController.for_cart(cart2.cart) TestingInvoiceController.for_cart(cart2.cart)
# Re-get inv1's invoice; it should void itself on loading. # Re-get inv1's invoice; it should void itself on loading.
inv1 = TestingInvoiceController(inv1.invoice) inv1 = TestingInvoiceController(inv1.invoice)

View file

@ -1,9 +1,9 @@
import pytz import pytz
from controller_helpers import TestingCartController from registrasion.tests.controller_helpers import TestingCartController
from controller_helpers import TestingInvoiceController from registrasion.tests.controller_helpers import TestingInvoiceController
from test_cart import RegistrationCartTestCase from registrasion.tests.test_cart import RegistrationCartTestCase
from registrasion.models import commerce from registrasion.models import commerce

View file

@ -1,12 +1,6 @@
import pytz import pytz
from django.core.exceptions import ValidationError
from registrasion.models import commerce
from registrasion.models import conditions from registrasion.models import conditions
from registrasion.controllers.category import CategoryController
from controller_helpers import TestingCartController
from controller_helpers import TestingInvoiceController
from registrasion.controllers.product import ProductController from registrasion.controllers.product import ProductController
from symposion.conference import models as conference_models from symposion.conference import models as conference_models
@ -16,7 +10,7 @@ from symposion.schedule import models as schedule_models
from symposion.speakers import models as speaker_models from symposion.speakers import models as speaker_models
from test_cart import RegistrationCartTestCase from registrasion.tests.test_cart import RegistrationCartTestCase
UTC = pytz.timezone('UTC') UTC = pytz.timezone('UTC')
@ -41,7 +35,7 @@ class SpeakerTestCase(RegistrationCartTestCase):
name="TEST_SECTION", name="TEST_SECTION",
slug="testsection", slug="testsection",
) )
proposal_section = proposal_models.ProposalSection.objects.create( proposal_section = proposal_models.ProposalSection.objects.create( # noqa
section=section, section=section,
closed=False, closed=False,
published=False, published=False,

View file

@ -8,10 +8,10 @@ from django.db import transaction
from registrasion.models import conditions from registrasion.models import conditions
from registrasion.models import inventory from registrasion.models import inventory
from controller_helpers import TestingCartController from registrasion.tests.controller_helpers import TestingCartController
from controller_helpers import TestingInvoiceController from registrasion.tests.controller_helpers import TestingInvoiceController
from test_cart import RegistrationCartTestCase from registrasion.tests.test_cart import RegistrationCartTestCase
UTC = pytz.timezone('UTC') UTC = pytz.timezone('UTC')
@ -21,7 +21,7 @@ class VoucherTestCases(RegistrationCartTestCase):
def test_apply_voucher(self): def test_apply_voucher(self):
voucher = self.new_voucher() voucher = self.new_voucher()
self.set_time(datetime.datetime(2015, 01, 01, tzinfo=UTC)) self.set_time(datetime.datetime(2015, 1, 1, tzinfo=UTC))
cart_1 = TestingCartController.for_user(self.USER_1) cart_1 = TestingCartController.for_user(self.USER_1)
cart_1.apply_voucher(voucher.code) cart_1.apply_voucher(voucher.code)

View file

@ -1,6 +1,4 @@
import datetime import datetime
import sys
from registrasion import util
import zipfile import zipfile
from registrasion import forms from registrasion import forms
@ -926,6 +924,7 @@ Email = namedtuple(
("subject", "body", "from_email", "recipient_list"), ("subject", "body", "from_email", "recipient_list"),
) )
@user_passes_test(_staff_only) @user_passes_test(_staff_only)
def invoice_mailout(request): def invoice_mailout(request):
''' Allows staff to send emails to users based on their invoice status. ''' ''' Allows staff to send emails to users based on their invoice status. '''
@ -951,8 +950,8 @@ def invoice_mailout(request):
subject = form.cleaned_data["subject"] subject = form.cleaned_data["subject"]
body = Template(form.cleaned_data["body"]).render( body = Template(form.cleaned_data["body"]).render(
Context({ Context({
"invoice" : invoice, "invoice": invoice,
"user" : invoice.user, "user": invoice.user,
}) })
) )
recipient_list = [invoice.user.email] recipient_list = [invoice.user.email]