From 4cdbdb71ceeebaed35d311025a3b7658fea9a35c 2016-04-25 07:37:33 From: Christopher Neugebauer Date: 2016-04-25 07:37:33 Subject: [PATCH] flake8 fixes --- diff --git a/registrasion/controllers/discount.py b/registrasion/controllers/discount.py index 6b9b7582b5be9be1a9b4b8d86b2346f8755dc458..e73928d03d50ca513bb5ff43a9272436ce8b4d21 100644 --- a/registrasion/controllers/discount.py +++ b/registrasion/controllers/discount.py @@ -71,7 +71,7 @@ def available_discounts(user, categories, products): # is not available any more. past_uses = commerce.DiscountItem.objects.filter( cart__user=user, - cart__status=commerce.Cart.STATUS_PAID, # Only past carts count + cart__status=commerce.Cart.STATUS_PAID, # Only past carts count discount=real_discount, ) agg = past_uses.aggregate(Sum("quantity")) diff --git a/registrasion/templatetags/registrasion_tags.py b/registrasion/templatetags/registrasion_tags.py index bd31d1f4d2ca05a4d97718acc0f3c79e23837234..fabc7754f9091972f525d40919b75704ae575623 100644 --- a/registrasion/templatetags/registrasion_tags.py +++ b/registrasion/templatetags/registrasion_tags.py @@ -10,6 +10,7 @@ register = template.Library() _ProductAndQuantity = namedtuple("ProductAndQuantity", ["product", "quantity"]) + class ProductAndQuantity(_ProductAndQuantity): ''' Class that holds a product and a quantity. diff --git a/registrasion/tests/test_cart.py b/registrasion/tests/test_cart.py index bf781bb132209c0540717b22c5d1763c786e2b2b..790c1df996470a8624fe98a929d8dd75feec13a3 100644 --- a/registrasion/tests/test_cart.py +++ b/registrasion/tests/test_cart.py @@ -26,12 +26,16 @@ class RegistrationCartTestCase(SetTimeMixin, TestCase): super(RegistrationCartTestCase, self).setUp() def tearDown(self): - if False: + if True: # If you're seeing segfaults in tests, enable this. - call_command('flush', verbosity=0, interactive=False, - reset_sequences=False, - allow_cascade=False, - inhibit_post_migrate=False) + call_command( + 'flush', + verbosity=0, + interactive=False, + reset_sequences=False, + allow_cascade=False, + inhibit_post_migrate=False + ) super(RegistrationCartTestCase, self).tearDown() @@ -51,11 +55,11 @@ class RegistrationCartTestCase(SetTimeMixin, TestCase): password='top_secret') attendee1 = people.Attendee.get_instance(cls.USER_1) - profile1 = people.AttendeeProfileBase.objects.create( + people.AttendeeProfileBase.objects.create( attendee=attendee1, ) attendee2 = people.Attendee.get_instance(cls.USER_2) - profile2 = people.AttendeeProfileBase.objects.create( + people.AttendeeProfileBase.objects.create( attendee=attendee2, ) diff --git a/registrasion/tests/test_invoice.py b/registrasion/tests/test_invoice.py index 9e5b55cf4603c90ea02e685adb7e18210caae6d8..f1ed6ed06cf4811e72fef4961438a61e8c67ac51 100644 --- a/registrasion/tests/test_invoice.py +++ b/registrasion/tests/test_invoice.py @@ -484,7 +484,7 @@ class InvoiceTestCase(RegistrationCartTestCase): invoice.pay("Paying into the void.", cnval, pre_validate=False) notes = commerce.CreditNote.objects.filter(invoice=invoice.invoice) - notes = sorted(notes, key = lambda note: note.value) + notes = sorted(notes, key=lambda note: note.value) self.assertEqual(cnval, notes[0].value) self.assertEqual(val, notes[1].value) diff --git a/registrasion/views.py b/registrasion/views.py index 19417b555fb17dc201cfacd91f3325a1338c5c0d..f10de90f6a72ff3dd27f6790399eeea6be979831 100644 --- a/registrasion/views.py +++ b/registrasion/views.py @@ -21,7 +21,6 @@ from django.contrib import messages from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ValidationError from django.http import Http404 -from django.shortcuts import get_object_or_404 from django.shortcuts import redirect from django.shortcuts import render @@ -42,17 +41,17 @@ class GuidedRegistrationSection(_GuidedRegistrationSection): ''' Represents a section of a guided registration page. Attributes: - title (str): The title of the section. + title (str): The title of the section. - discounts ([registrasion.contollers.discount.DiscountAndQuantity, ...]): + discounts ([registrasion.contollers.discount.DiscountAndQuantity, ...]): A list of discount objects that are available in the section. You can display ``.clause`` to show what the discount applies to, and ``.quantity`` to display the number of times that discount can be applied. - description (str): A description of the section. + description (str): A description of the section. - form (forms.Form): A form to display. + form (forms.Form): A form to display. ''' pass @@ -569,7 +568,6 @@ def invoice_access(request, access_code): user__attendee__access_code=access_code, ).order_by("-issue_time") - if not invoices: raise Http404() @@ -635,6 +633,7 @@ def _staff_only(user): ''' Returns true if the user is staff. ''' return user.is_staff + @user_passes_test(_staff_only) def manual_payment(request, invoice_id): ''' Allows staff to make manual payments or refunds on an invoice. diff --git a/setup.cfg b/setup.cfg index 257d3cd62d52817fd51b522449e54a156097c868..290fdb45c343748a4cded2fb35a057cc023195be 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [flake8] -exclude = registrasion/migrations/*, build/* +exclude = registrasion/migrations/*, build/*, docs/*