Refactors the email form into an InvoicesWithProductAndStatus form
This commit is contained in:
parent
78714600bf
commit
4fc494783d
1 changed files with 25 additions and 22 deletions
|
@ -413,31 +413,11 @@ def staff_products_formset_factory(user):
|
||||||
return forms.formset_factory(form_type)
|
return forms.formset_factory(form_type)
|
||||||
|
|
||||||
|
|
||||||
class InvoiceEmailForm(forms.Form):
|
class InvoicesWithProductAndStatusForm(forms.Form):
|
||||||
|
|
||||||
ACTION_PREVIEW = 1
|
|
||||||
ACTION_SEND = 2
|
|
||||||
|
|
||||||
ACTION_CHOICES = (
|
|
||||||
(ACTION_PREVIEW, "Preview"),
|
|
||||||
(ACTION_SEND, "Send emails"),
|
|
||||||
)
|
|
||||||
|
|
||||||
invoice = forms.ModelMultipleChoiceField(
|
invoice = forms.ModelMultipleChoiceField(
|
||||||
widget=forms.CheckboxSelectMultiple,
|
widget=forms.CheckboxSelectMultiple,
|
||||||
queryset=commerce.Invoice.objects.all(),
|
queryset=commerce.Invoice.objects.all(),
|
||||||
)
|
)
|
||||||
from_email = forms.CharField()
|
|
||||||
subject = forms.CharField()
|
|
||||||
body = forms.CharField(
|
|
||||||
widget=forms.Textarea,
|
|
||||||
)
|
|
||||||
action = forms.TypedChoiceField(
|
|
||||||
widget=forms.RadioSelect,
|
|
||||||
coerce=int,
|
|
||||||
choices=ACTION_CHOICES,
|
|
||||||
initial=ACTION_PREVIEW,
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, *a, **k):
|
def __init__(self, *a, **k):
|
||||||
category = k.pop('category', None) or []
|
category = k.pop('category', None) or []
|
||||||
|
@ -447,7 +427,7 @@ class InvoiceEmailForm(forms.Form):
|
||||||
category = [int(i) for i in category]
|
category = [int(i) for i in category]
|
||||||
product = [int(i) for i in product]
|
product = [int(i) for i in product]
|
||||||
|
|
||||||
super(InvoiceEmailForm, self).__init__(*a, **k)
|
super(InvoicesWithProductAndStatusForm, self).__init__(*a, **k)
|
||||||
print status
|
print status
|
||||||
|
|
||||||
qs = commerce.Invoice.objects.filter(
|
qs = commerce.Invoice.objects.filter(
|
||||||
|
@ -464,3 +444,26 @@ class InvoiceEmailForm(forms.Form):
|
||||||
|
|
||||||
self.fields['invoice'].queryset = qs
|
self.fields['invoice'].queryset = qs
|
||||||
self.fields['invoice'].initial = [i.id for i in qs]
|
self.fields['invoice'].initial = [i.id for i in qs]
|
||||||
|
|
||||||
|
|
||||||
|
class InvoiceEmailForm(InvoicesWithProductAndStatusForm):
|
||||||
|
|
||||||
|
ACTION_PREVIEW = 1
|
||||||
|
ACTION_SEND = 2
|
||||||
|
|
||||||
|
ACTION_CHOICES = (
|
||||||
|
(ACTION_PREVIEW, "Preview"),
|
||||||
|
(ACTION_SEND, "Send emails"),
|
||||||
|
)
|
||||||
|
|
||||||
|
from_email = forms.CharField()
|
||||||
|
subject = forms.CharField()
|
||||||
|
body = forms.CharField(
|
||||||
|
widget=forms.Textarea,
|
||||||
|
)
|
||||||
|
action = forms.TypedChoiceField(
|
||||||
|
widget=forms.RadioSelect,
|
||||||
|
coerce=int,
|
||||||
|
choices=ACTION_CHOICES,
|
||||||
|
initial=ACTION_PREVIEW,
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue