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: | ||||
|         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.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 contextlib | ||||
| import datetime | ||||
| import functools | ||||
| import itertools | ||||
|  | @ -16,12 +21,6 @@ from registrasion.models import commerce | |||
| from registrasion.models import conditions | ||||
| 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): | ||||
|     ''' Decorator that makes the wrapped function raise ValidationError | ||||
|  | @ -94,7 +93,6 @@ class CartController(object): | |||
|         self.cart.time_last_updated = timezone.now() | ||||
|         self.cart.reservation_duration = max(reservations) | ||||
| 
 | ||||
| 
 | ||||
|     def end_batch(self): | ||||
|         ''' Calls ``_end_batch`` if a modification has been performed in the | ||||
|         previous batch. ''' | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ from django.db.models import Value | |||
| 
 | ||||
| from .batch import BatchController | ||||
| 
 | ||||
| 
 | ||||
| class AllProducts(object): | ||||
|     pass | ||||
| 
 | ||||
|  |  | |||
|  | @ -12,6 +12,7 @@ from django.db.models import Sum | |||
| from django.db.models import Value | ||||
| from django.db.models import When | ||||
| 
 | ||||
| 
 | ||||
| class DiscountAndQuantity(object): | ||||
|     ''' Represents a discount that can be applied to a product or category | ||||
|     for a given user. | ||||
|  |  | |||
|  | @ -1,5 +1,4 @@ | |||
| import itertools | ||||
| import operator | ||||
| 
 | ||||
| from collections import defaultdict | ||||
| from collections import namedtuple | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ from registrasion.models import commerce | |||
| from registrasion.models import inventory | ||||
| 
 | ||||
| from django import forms | ||||
| from django.core.exceptions import ValidationError | ||||
| 
 | ||||
| 
 | ||||
| class ApplyCreditNoteForm(forms.Form): | ||||
|  | @ -54,10 +53,11 @@ def ProductsForm(category, products): | |||
|     type. ''' | ||||
| 
 | ||||
|     # Each Category.RENDER_TYPE value has a subclass here. | ||||
|     cat = inventory.Category | ||||
|     RENDER_TYPES = { | ||||
|         inventory.Category.RENDER_TYPE_QUANTITY: _QuantityBoxProductsForm, | ||||
|         inventory.Category.RENDER_TYPE_RADIO: _RadioButtonProductsForm, | ||||
|         inventory.Category.RENDER_TYPE_ITEM_QUANTITY: _ItemQuantityProductsForm, | ||||
|         cat.RENDER_TYPE_QUANTITY: _QuantityBoxProductsForm, | ||||
|         cat.RENDER_TYPE_RADIO: _RadioButtonProductsForm, | ||||
|         cat.RENDER_TYPE_ITEM_QUANTITY: _ItemQuantityProductsForm, | ||||
|     } | ||||
| 
 | ||||
|     # 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): | ||||
|         self.add_error(cls.FIELD, error) | ||||
|         self.add_error(self.FIELD, error) | ||||
| 
 | ||||
| 
 | ||||
| class _ItemQuantityProductsForm(_ProductsForm): | ||||
|     ''' Products entry form that allows users to select a product type, and | ||||
|      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 | ||||
|      _ItemQuantityProductsFormSet to allow selection of multiple products.''' | ||||
|      product type to be purchased. This form is usually used in concert with | ||||
|      the _ItemQuantityProductsFormSet to allow selection of multiple | ||||
|      products.''' | ||||
| 
 | ||||
|     CHOICE_FIELD = "choice" | ||||
|     QUANTITY_FIELD = "quantity" | ||||
|  |  | |||
|  | @ -2,6 +2,7 @@ from django.utils import timezone | |||
| 
 | ||||
| from registrasion.contrib import mail | ||||
| 
 | ||||
| 
 | ||||
| class SetTimeMixin(object): | ||||
|     ''' Patches timezone.now() for the duration of a test case. Allows us to | ||||
|     test time-based conditions (ceilings etc) relatively easily. ''' | ||||
|  |  | |||
|  | @ -1,16 +1,8 @@ | |||
| import datetime | ||||
| import pytz | ||||
| 
 | ||||
| from django.core.exceptions import ValidationError | ||||
| 
 | ||||
| from controller_helpers import TestingCartController | ||||
| from test_cart import RegistrationCartTestCase | ||||
| 
 | ||||
| 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') | ||||
| 
 | ||||
|  | @ -124,6 +116,7 @@ class BatchTestCase(RegistrationCartTestCase): | |||
|     def test_batch_end_functionality_is_called(self): | ||||
|         class Ender(object): | ||||
|             end_count = 0 | ||||
| 
 | ||||
|             def end_batch(self): | ||||
|                 self.end_count += 1 | ||||
| 
 | ||||
|  |  | |||
|  | @ -375,7 +375,7 @@ class BasicCartTests(RegistrationCartTestCase): | |||
| 
 | ||||
|         with BatchController.batch(self.USER_1): | ||||
|             # Memoise the cart | ||||
|             same_cart = TestingCartController.for_user(self.USER_1) | ||||
|             TestingCartController.for_user(self.USER_1) | ||||
|             # Do nothing on exit | ||||
| 
 | ||||
|         rev_1 = self.reget(cart.cart).revision | ||||
|  |  | |||
|  | @ -1,4 +1,3 @@ | |||
| import views | ||||
| from reporting import views as reporting_views | ||||
| 
 | ||||
| from django.conf.urls import include | ||||
|  | @ -38,7 +37,11 @@ public = [ | |||
| 
 | ||||
| reports = [ | ||||
|     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( | ||||
|         r"^product_status/?$", | ||||
|         reporting_views.product_status, | ||||
|  |  | |||
|  | @ -355,7 +355,10 @@ def product_category(request, category_id): | |||
|         if not products: | ||||
|             messages.warning( | ||||
|                 request, | ||||
|                 "There are no products available from category: " + category.name, | ||||
|                 ( | ||||
|                     "There are no products available from category: " + | ||||
|                     category.name | ||||
|                 ), | ||||
|             ) | ||||
|             return redirect("dashboard") | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Christopher Neugebauer
						Christopher Neugebauer