diff --git a/mails/forms.py b/mails/forms.py index 967b6a72b3768c73260b0046be7295c10557d549..81bd732bc4bcc62f8ff80d47ba1915adffcafd64 100644 --- a/mails/forms.py +++ b/mails/forms.py @@ -19,7 +19,8 @@ class EmailTemplateForm(forms.Form, MailUtilsMixin): # This form shouldn't be is_bound==True is there is any non-relavant POST data given. data = args[0] if args else {} - data = kwargs['data'] if 'data' in kwargs else data + if not data: + data = {} if '%s-subject' % self.prefix in data.keys(): data = { '%s-subject' % self.prefix: data.get('%s-subject' % self.prefix), @@ -30,7 +31,7 @@ class EmailTemplateForm(forms.Form, MailUtilsMixin): data = None super().__init__(data or None) - if self.original_recipient == '': + if not self.original_recipient: self.fields['extra_recipient'].label = "Send this email to" self.fields['extra_recipient'].required = True @@ -50,7 +51,7 @@ class EmailTemplateForm(forms.Form, MailUtilsMixin): self.bcc_list.append(self.cleaned_data.get('extra_recipient')) elif self.cleaned_data.get('extra_recipient') and not self.original_recipient: self.original_recipient = [self.cleaned_data.get('extra_recipient')] - elif self.original_recipient == '': + elif not self.original_recipient: self.add_error('extra_recipient', 'Please fill the bcc field to send the mail.') self.validate_recipients() @@ -61,9 +62,6 @@ class EmailTemplateForm(forms.Form, MailUtilsMixin): self.save_data() return data - def save(self): - return self.instance - class HiddenDataForm(forms.Form): def __init__(self, form, *args, **kwargs):