mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Fixed misc. issues relative to the 'compose form' validation process.
fix #203
This commit is contained in:
@@ -5,7 +5,7 @@ class ComposeMailForm(forms.Form):
|
||||
from_ = forms.CharField(label=_("From"))
|
||||
to = forms.CharField(label=_("To"), widget=forms.Textarea())
|
||||
cc = forms.CharField(label=_("Cc"), widget=forms.Textarea(), required=False)
|
||||
subject = forms.CharField(label=_("Subject"), max_length=255)
|
||||
subject = forms.CharField(label=_("Subject"), max_length=255, required=False)
|
||||
|
||||
class FolderForm(forms.Form):
|
||||
name = forms.CharField()
|
||||
|
||||
@@ -734,7 +734,7 @@ def send_mail(request, origmsg=None, posturl=None):
|
||||
"""
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from forms import ComposeMailForm
|
||||
from modoboa.lib.webutils import getctx, ajax_simple_response
|
||||
from modoboa.lib.webutils import getctx, ajax_simple_response, _render_to_string
|
||||
from modoboa.auth.lib import get_password
|
||||
|
||||
form = ComposeMailForm(request.POST)
|
||||
@@ -815,13 +815,13 @@ def send_mail(request, origmsg=None, posturl=None):
|
||||
del request.session["compose_mail"]
|
||||
return True, ajax_simple_response(getctx("ok", url=get_current_url(request)))
|
||||
|
||||
|
||||
listing = render_to_string("webmail/compose.html",
|
||||
{"form" : form,
|
||||
listing = _render_to_string(request, "webmail/compose.html",
|
||||
{"form" : form, "noerrors" : True,
|
||||
"body" : request.POST["id_body"].strip(),
|
||||
"posturl" : posturl})
|
||||
error = _("Red fields are mandatories")
|
||||
return False, ajax_simple_response(
|
||||
getctx("ko", level=2, listing=listing, editor=editormode)
|
||||
getctx("ko", level=2, respmsg=error, listing=listing, editor=editormode)
|
||||
)
|
||||
|
||||
class AttachmentUploadHandler(FileUploadHandler):
|
||||
|
||||
@@ -104,6 +104,8 @@ function sendmail_callback(evt) {
|
||||
current_anchor.get_callback("compose")(resp);
|
||||
if ($defined(resp.respmsg)) {
|
||||
infobox.error(resp.respmsg);
|
||||
} else {
|
||||
infobox.hide();
|
||||
}
|
||||
enable_link(this, sendmail_callback);
|
||||
return;
|
||||
|
||||
@@ -403,6 +403,11 @@ div.row label {
|
||||
padding: 3px 0;
|
||||
}
|
||||
|
||||
.missing input,
|
||||
.missing textarea {
|
||||
background-color: #F9D2D2;
|
||||
}
|
||||
|
||||
.error {
|
||||
margin: 0 auto;
|
||||
padding: 5px;
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
<div class="tip-text">{% trans field.help_text %}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<label for="id_{{ field.html_name }}">{% trans field.label %}</label><div class="input_container clearfix"> {{ field }}</div> {% ifequal noerrors False %}{{ field.errors }}{% endifequal %}
|
||||
<label for="id_{{ field.html_name }}">{% trans field.label %}</label><div class="input_container clearfix {% if field.errors %}missing{% endif %}"> {{ field }}</div> {% ifequal noerrors False %}{{ field.errors }}{% endifequal %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user