diff --git a/modoboa/userprefs/forms.py b/modoboa/userprefs/forms.py index d9292a51a..ee75d19fe 100644 --- a/modoboa/userprefs/forms.py +++ b/modoboa/userprefs/forms.py @@ -52,12 +52,24 @@ class ProfileForm(forms.ModelForm): return user class ForwardForm(forms.Form): - dest = forms.CharField(label=ugettext_lazy("Destination(s)"), widget=forms.Textarea) - keepcopies = forms.BooleanField(label=ugettext_lazy("Keep local copies"), required=False) + dest = forms.CharField( + label=ugettext_lazy("Recipient(s)"), + widget=forms.Textarea, + required=False, + help_text=ugettext_lazy("Indicate one or more recipients separated by a ','") + ) + keepcopies = forms.BooleanField( + label=ugettext_lazy("Keep local copies"), + required=False, + help_text=ugettext_lazy("Forward messages and store copies into your local mailbox") + ) def parse_dest(self): self.dests = [] - for d in self.cleaned_data["dest"].strip().split(","): + rawdata = self.cleaned_data["dest"].strip() + if rawdata == "": + return + for d in rawdata.split(","): local_part, domname = split_mailbox(d) if not local_part or not domname or not len(domname): raise BadDestination("Invalid mailbox syntax for %s" % d) diff --git a/modoboa/userprefs/templates/userprefs/section.html b/modoboa/userprefs/templates/userprefs/section.html index fd622adb5..d46aac5d2 100644 --- a/modoboa/userprefs/templates/userprefs/section.html +++ b/modoboa/userprefs/templates/userprefs/section.html @@ -11,6 +11,9 @@ $(document).ready(function() { $("body").notify("success", data.respmsg, 2000); } else { $("#form").html(data.content); + if (data.respmsg) { + $("body").notify("error", data.respmsg); + } } }); }); diff --git a/modoboa/userprefs/views.py b/modoboa/userprefs/views.py index 0ce80aa02..e6758a3f1 100644 --- a/modoboa/userprefs/views.py +++ b/modoboa/userprefs/views.py @@ -52,8 +52,13 @@ def forward(request): return ajax_response(request, respmsg=_("Forward updated")) except BadDestination, e: error = str(e) + ctx.update(form=form, error=error) - return ajax_response(request, status="ko", template="userprefs/form.html", **ctx) + return ajax_simple_response(dict( + status="ko", + content=render_to_string("userprefs/form.html", dict(form=form)), + respmsg=error + )) form = ForwardForm() if al is not None: