Forms for nag e-mail

This commit is contained in:
Christopher Neugebauer 2016-12-07 11:52:10 +11:00
parent fcf4e5cffb
commit 051a942ffe
3 changed files with 17 additions and 4 deletions

View file

@ -402,6 +402,9 @@ class InvoiceNagForm(forms.Form):
widget=forms.CheckboxSelectMultiple,
queryset=commerce.Invoice.objects.all(),
)
message = forms.CharField(
widget=forms.Textarea,
)
def __init__(self, *a, **k):
category = k.pop('category', None) or []
@ -412,8 +415,6 @@ class InvoiceNagForm(forms.Form):
super(InvoiceNagForm, self).__init__(*a, **k)
print repr(category), repr(product)
qs = commerce.Invoice.objects.filter(
status=commerce.Invoice.STATUS_UNPAID,
).filter(
@ -421,4 +422,10 @@ class InvoiceNagForm(forms.Form):
Q(lineitem__product__in=product)
)
# Uniqify
qs = commerce.Invoice.objects.filter(
id__in=qs,
)
self.fields['invoice'].queryset = qs
self.fields['invoice'].initial = [i.id for i in qs]

View file

@ -152,7 +152,9 @@ class Invoice(models.Model):
]
def __str__(self):
return "Invoice #%d" % self.id
return "Invoice #%d (to: %s, due: %s, value: %s)" % (
self.id, self.user.email, self.due_time, self.value
)
def clean(self):
if self.cart is not None and self.cart_revision is None:

View file

@ -931,4 +931,8 @@ def nag_unpaid(request):
product=product,
)
print form.fields['invoice'].queryset
data = {
"form": form,
}
return render(request, "registrasion/nag_unpaid.html", data)