Factors _ProductsForm into _HasProductsFields

This commit is contained in:
Christopher Neugebauer 2016-08-22 10:13:02 +10:00
parent 64e897919e
commit 8c34c7498a

View file

@ -47,7 +47,7 @@ class ManualPaymentForm(forms.ModelForm):
# Products forms -- none of these have any fields: they are to be subclassed # Products forms -- none of these have any fields: they are to be subclassed
# and the fields added as needs be. # and the fields added as needs be.
class _ProductsForm(forms.Form): class _HasProductsFields(object):
PRODUCT_PREFIX = "product_" PRODUCT_PREFIX = "product_"
@ -57,7 +57,7 @@ class _ProductsForm(forms.Form):
initial = self.initial_data(k["product_quantities"]) initial = self.initial_data(k["product_quantities"])
k["initial"] = initial k["initial"] = initial
del k["product_quantities"] del k["product_quantities"]
super(_ProductsForm, self).__init__(*a, **k) super(_ProductsFieldsHelpers, self).__init__(*a, **k)
@classmethod @classmethod
def field_name(cls, product): def field_name(cls, product):
@ -81,6 +81,10 @@ class _ProductsForm(forms.Form):
return iter([]) return iter([])
class _ProductsForm(_HasProductsFields, forms.Form):
pass
class _QuantityBoxProductsForm(_ProductsForm): class _QuantityBoxProductsForm(_ProductsForm):
''' Products entry form that allows users to enter quantities ''' Products entry form that allows users to enter quantities
of desired products. ''' of desired products. '''