From 051a942ffe6637046ff7b24fe86580c1f330aec0 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Wed, 7 Dec 2016 11:52:10 +1100 Subject: [PATCH] Forms for nag e-mail --- registrasion/forms.py | 11 +++++++++-- registrasion/models/commerce.py | 4 +++- registrasion/views.py | 6 +++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/registrasion/forms.py b/registrasion/forms.py index 150219f1..bf6549b7 100644 --- a/registrasion/forms.py +++ b/registrasion/forms.py @@ -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] diff --git a/registrasion/models/commerce.py b/registrasion/models/commerce.py index 8c8bcd9b..72ece2c8 100644 --- a/registrasion/models/commerce.py +++ b/registrasion/models/commerce.py @@ -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: diff --git a/registrasion/views.py b/registrasion/views.py index 0e62a649..a65b4a7b 100644 --- a/registrasion/views.py +++ b/registrasion/views.py @@ -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)