Changeset - 0b7ccfc82719
[Not reviewed]
0 1 0
Christopher Neugebauer - 8 years ago 2016-04-06 12:59:00
chrisjrn@gmail.com
Enforces minimum quantity of 0 for quantity boxes
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
registrasion/forms.py
Show inline comments
...
 
@@ -46,24 +46,25 @@ class _QuantityBoxProductsForm(_ProductsForm):
 

	
 
    @classmethod
 
    def set_fields(cls, category, products):
 
        for product in products:
 
            if product.description:
 
                help_text = "$%d each -- %s" % (product.price, product.description)
 
            else:
 
                help_text = "$%d each" % product.price
 

	
 
            field = forms.IntegerField(
 
                label=product.name,
 
                help_text=help_text,
 
                min_value=0,
 
            )
 
            cls.base_fields[cls.field_name(product)] = field
 

	
 
    @classmethod
 
    def initial_data(cls, product_quantities):
 
        initial = {}
 
        for product, quantity in product_quantities:
 
            initial[cls.field_name(product)] = quantity
 

	
 
        return initial
 

	
 
    def product_quantities(self):
0 comments (0 inline, 0 general)