Fixes flake8 snafus
This commit is contained in:
		
							parent
							
								
									4b6b221086
								
							
						
					
					
						commit
						64ca477cb8
					
				
					 11 changed files with 38 additions and 31 deletions
				
			
		|  | @ -58,6 +58,12 @@ def __send_email__(template_prefix, to, kind, **kwargs): | ||||||
|     except AttributeError: |     except AttributeError: | ||||||
|         bcc_email = None |         bcc_email = None | ||||||
| 
 | 
 | ||||||
|     email = EmailMultiAlternatives(subject, message_plaintext, from_email, to, bcc=bcc_email) |     email = EmailMultiAlternatives( | ||||||
|  |         subject, | ||||||
|  |         message_plaintext, | ||||||
|  |         from_email, | ||||||
|  |         to, | ||||||
|  |         bcc=bcc_email, | ||||||
|  |     ) | ||||||
|     email.attach_alternative(message_html, "text/html") |     email.attach_alternative(message_html, "text/html") | ||||||
|     email.send() |     email.send() | ||||||
|  |  | ||||||
|  | @ -1,5 +1,10 @@ | ||||||
|  | from .batch import BatchController | ||||||
|  | from .category import CategoryController | ||||||
|  | from .discount import DiscountController | ||||||
|  | from .flag import FlagController | ||||||
|  | from .product import ProductController | ||||||
|  | 
 | ||||||
| import collections | import collections | ||||||
| import contextlib |  | ||||||
| import datetime | import datetime | ||||||
| import functools | import functools | ||||||
| import itertools | import itertools | ||||||
|  | @ -16,12 +21,6 @@ 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.batch import BatchController |  | ||||||
| from .category import CategoryController |  | ||||||
| from .discount import DiscountController |  | ||||||
| from .flag import FlagController |  | ||||||
| from .product import ProductController |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| def _modifies_cart(func): | def _modifies_cart(func): | ||||||
|     ''' Decorator that makes the wrapped function raise ValidationError |     ''' Decorator that makes the wrapped function raise ValidationError | ||||||
|  | @ -94,11 +93,10 @@ class CartController(object): | ||||||
|         self.cart.time_last_updated = timezone.now() |         self.cart.time_last_updated = timezone.now() | ||||||
|         self.cart.reservation_duration = max(reservations) |         self.cart.reservation_duration = max(reservations) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     def end_batch(self): |     def end_batch(self): | ||||||
|         ''' Calls ``_end_batch`` if a modification has been performed in the |         ''' Calls ``_end_batch`` if a modification has been performed in the | ||||||
|         previous batch. ''' |         previous batch. ''' | ||||||
|         if hasattr(self,'_modified_by_batch'): |         if hasattr(self, '_modified_by_batch'): | ||||||
|             self._end_batch() |             self._end_batch() | ||||||
| 
 | 
 | ||||||
|     def _end_batch(self): |     def _end_batch(self): | ||||||
|  |  | ||||||
|  | @ -9,6 +9,7 @@ from django.db.models import Value | ||||||
| 
 | 
 | ||||||
| from .batch import BatchController | from .batch import BatchController | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| class AllProducts(object): | class AllProducts(object): | ||||||
|     pass |     pass | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -12,6 +12,7 @@ from django.db.models import Sum | ||||||
| from django.db.models import Value | from django.db.models import Value | ||||||
| from django.db.models import When | from django.db.models import When | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| class DiscountAndQuantity(object): | class DiscountAndQuantity(object): | ||||||
|     ''' Represents a discount that can be applied to a product or category |     ''' Represents a discount that can be applied to a product or category | ||||||
|     for a given user. |     for a given user. | ||||||
|  |  | ||||||
|  | @ -1,5 +1,4 @@ | ||||||
| import itertools | import itertools | ||||||
| import operator |  | ||||||
| 
 | 
 | ||||||
| from collections import defaultdict | from collections import defaultdict | ||||||
| from collections import namedtuple | from collections import namedtuple | ||||||
|  |  | ||||||
|  | @ -2,7 +2,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 |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class ApplyCreditNoteForm(forms.Form): | class ApplyCreditNoteForm(forms.Form): | ||||||
|  | @ -54,10 +53,11 @@ def ProductsForm(category, products): | ||||||
|     type. ''' |     type. ''' | ||||||
| 
 | 
 | ||||||
|     # Each Category.RENDER_TYPE value has a subclass here. |     # Each Category.RENDER_TYPE value has a subclass here. | ||||||
|  |     cat = inventory.Category | ||||||
|     RENDER_TYPES = { |     RENDER_TYPES = { | ||||||
|         inventory.Category.RENDER_TYPE_QUANTITY: _QuantityBoxProductsForm, |         cat.RENDER_TYPE_QUANTITY: _QuantityBoxProductsForm, | ||||||
|         inventory.Category.RENDER_TYPE_RADIO: _RadioButtonProductsForm, |         cat.RENDER_TYPE_RADIO: _RadioButtonProductsForm, | ||||||
|         inventory.Category.RENDER_TYPE_ITEM_QUANTITY: _ItemQuantityProductsForm, |         cat.RENDER_TYPE_ITEM_QUANTITY: _ItemQuantityProductsForm, | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     # 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 | ||||||
|  | @ -211,13 +211,15 @@ class _RadioButtonProductsForm(_ProductsForm): | ||||||
|             ) |             ) | ||||||
| 
 | 
 | ||||||
|     def add_product_error(self, product, error): |     def add_product_error(self, product, error): | ||||||
|         self.add_error(cls.FIELD, error) |         self.add_error(self.FIELD, error) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| class _ItemQuantityProductsForm(_ProductsForm): | class _ItemQuantityProductsForm(_ProductsForm): | ||||||
|     ''' Products entry form that allows users to select a product type, and |     ''' Products entry form that allows users to select a product type, and | ||||||
|      enter a quantity of that product. This version _only_ allows a single |      enter a quantity of that product. This version _only_ allows a single | ||||||
|      product type to be purchased. This form is usually used in concert with the |      product type to be purchased. This form is usually used in concert with | ||||||
|      _ItemQuantityProductsFormSet to allow selection of multiple products.''' |      the _ItemQuantityProductsFormSet to allow selection of multiple | ||||||
|  |      products.''' | ||||||
| 
 | 
 | ||||||
|     CHOICE_FIELD = "choice" |     CHOICE_FIELD = "choice" | ||||||
|     QUANTITY_FIELD = "quantity" |     QUANTITY_FIELD = "quantity" | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ from django.utils import timezone | ||||||
| 
 | 
 | ||||||
| from registrasion.contrib import mail | from registrasion.contrib import mail | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| class SetTimeMixin(object): | class SetTimeMixin(object): | ||||||
|     ''' Patches timezone.now() for the duration of a test case. Allows us to |     ''' Patches timezone.now() for the duration of a test case. Allows us to | ||||||
|     test time-based conditions (ceilings etc) relatively easily. ''' |     test time-based conditions (ceilings etc) relatively easily. ''' | ||||||
|  |  | ||||||
|  | @ -1,16 +1,8 @@ | ||||||
| import datetime |  | ||||||
| import pytz | import pytz | ||||||
| 
 | 
 | ||||||
| from django.core.exceptions import ValidationError |  | ||||||
| 
 |  | ||||||
| from controller_helpers import TestingCartController |  | ||||||
| from test_cart import RegistrationCartTestCase | from test_cart import RegistrationCartTestCase | ||||||
| 
 | 
 | ||||||
| from registrasion.controllers.batch import BatchController | from registrasion.controllers.batch import BatchController | ||||||
| from registrasion.controllers.discount import DiscountController |  | ||||||
| from registrasion.controllers.product import ProductController |  | ||||||
| from registrasion.models import commerce |  | ||||||
| from registrasion.models import conditions |  | ||||||
| 
 | 
 | ||||||
| UTC = pytz.timezone('UTC') | UTC = pytz.timezone('UTC') | ||||||
| 
 | 
 | ||||||
|  | @ -124,6 +116,7 @@ class BatchTestCase(RegistrationCartTestCase): | ||||||
|     def test_batch_end_functionality_is_called(self): |     def test_batch_end_functionality_is_called(self): | ||||||
|         class Ender(object): |         class Ender(object): | ||||||
|             end_count = 0 |             end_count = 0 | ||||||
|  | 
 | ||||||
|             def end_batch(self): |             def end_batch(self): | ||||||
|                 self.end_count += 1 |                 self.end_count += 1 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -375,7 +375,7 @@ class BasicCartTests(RegistrationCartTestCase): | ||||||
| 
 | 
 | ||||||
|         with BatchController.batch(self.USER_1): |         with BatchController.batch(self.USER_1): | ||||||
|             # Memoise the cart |             # Memoise the cart | ||||||
|             same_cart = TestingCartController.for_user(self.USER_1) |             TestingCartController.for_user(self.USER_1) | ||||||
|             # Do nothing on exit |             # Do nothing on exit | ||||||
| 
 | 
 | ||||||
|         rev_1 = self.reget(cart.cart).revision |         rev_1 = self.reget(cart.cart).revision | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| import views |  | ||||||
| from reporting import views as reporting_views | from reporting import views as reporting_views | ||||||
| 
 | 
 | ||||||
| from django.conf.urls import include | from django.conf.urls import include | ||||||
|  | @ -38,7 +37,11 @@ public = [ | ||||||
| 
 | 
 | ||||||
| reports = [ | reports = [ | ||||||
|     url(r"^$", reporting_views.reports_list, name="reports_list"), |     url(r"^$", reporting_views.reports_list, name="reports_list"), | ||||||
|     url(r"^credit_notes/?$", reporting_views.credit_notes, name="credit_notes"), |     url( | ||||||
|  |         r"^credit_notes/?$", | ||||||
|  |         reporting_views.credit_notes, | ||||||
|  |         name="credit_notes" | ||||||
|  |     ), | ||||||
|     url( |     url( | ||||||
|         r"^product_status/?$", |         r"^product_status/?$", | ||||||
|         reporting_views.product_status, |         reporting_views.product_status, | ||||||
|  |  | ||||||
|  | @ -355,7 +355,10 @@ def product_category(request, category_id): | ||||||
|         if not products: |         if not products: | ||||||
|             messages.warning( |             messages.warning( | ||||||
|                 request, |                 request, | ||||||
|                 "There are no products available from category: " + category.name, |                 ( | ||||||
|  |                     "There are no products available from category: " + | ||||||
|  |                     category.name | ||||||
|  |                 ), | ||||||
|             ) |             ) | ||||||
|             return redirect("dashboard") |             return redirect("dashboard") | ||||||
| 
 | 
 | ||||||
|  | @ -456,7 +459,7 @@ def _set_quantities_from_products_form(products_form, current_cart): | ||||||
|         id__in=pks, |         id__in=pks, | ||||||
|     ).select_related("category").order_by("id") |     ).select_related("category").order_by("id") | ||||||
| 
 | 
 | ||||||
|     quantities.sort(key = lambda i: i[0]) |     quantities.sort(key=lambda i: i[0]) | ||||||
| 
 | 
 | ||||||
|     # Match the product objects to their quantities |     # Match the product objects to their quantities | ||||||
|     product_quantities = [ |     product_quantities = [ | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Christopher Neugebauer
						Christopher Neugebauer