You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
533 B

  1. from django import forms
  2. from hc.accounts.forms import LowercaseEmailField
  3. class InvoiceEmailingForm(forms.Form):
  4. send_invoices = forms.IntegerField(min_value=0, max_value=2)
  5. invoice_email = LowercaseEmailField(required=False)
  6. def update_subscription(self, sub):
  7. sub.send_invoices = self.cleaned_data["send_invoices"] > 0
  8. if self.cleaned_data["send_invoices"] == 2:
  9. sub.invoice_email = self.cleaned_data["invoice_email"]
  10. else:
  11. sub.invoice_email = ""
  12. sub.save()