mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
fix: the untildate field is not mandatory!
This commit is contained in:
@@ -4,9 +4,12 @@ from django.utils.translation import ugettext as _
|
||||
import datetime
|
||||
|
||||
class ARmessageForm(forms.ModelForm):
|
||||
untildate = forms.DateField(label=_('Until'), required=False,
|
||||
help_text=_("Activate your auto reply until this date"))
|
||||
|
||||
class Meta:
|
||||
model = ARmessage
|
||||
fields = ('subject', 'content', 'enabled', 'untildate')
|
||||
fields = ('subject', 'content', 'enabled')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ARmessageForm, self).__init__(*args, **kwargs)
|
||||
@@ -14,6 +17,7 @@ class ARmessageForm(forms.ModelForm):
|
||||
self.fields['content'].widget.attrs['cols'] = 50
|
||||
|
||||
def clean_untildate(self):
|
||||
if self.cleaned_data["untildate"] < datetime.date.today():
|
||||
raise forms.ValidationError(_("This date is over"))
|
||||
if self.cleaned_data["untildate"] is not None:
|
||||
if self.cleaned_data["untildate"] < datetime.date.today():
|
||||
raise forms.ValidationError(_("This date is over"))
|
||||
return self.cleaned_data['untildate']
|
||||
|
||||
@@ -55,7 +55,7 @@ def menu(**kwargs):
|
||||
"url" : reverse(views.autoreply),
|
||||
"img" : "/static/pics/auto-reply.png",
|
||||
"class" : "boxed",
|
||||
"rel" : "{handler:'iframe',size:{x:440,y:370}}",
|
||||
"rel" : "{handler:'iframe',size:{x:440,y:400}}",
|
||||
"label" : _("Auto-reply message")}
|
||||
]
|
||||
|
||||
|
||||
@@ -18,8 +18,7 @@ class ARmessage(models.Model):
|
||||
help_text=_("The content that will appear in sended emails"))
|
||||
enabled = models.BooleanField(_('enabled'),
|
||||
help_text=_("Activate/Deactivate your auto reply"))
|
||||
untildate = models.DateField(_('until'),
|
||||
help_text=_("Activate your auto reply until this date"))
|
||||
untildate = models.DateField()
|
||||
|
||||
class ARhistoric(models.Model):
|
||||
armessage = models.ForeignKey(ARmessage)
|
||||
|
||||
@@ -29,6 +29,7 @@ def autoreply(request):
|
||||
from modoboa import userprefs
|
||||
|
||||
arm = form.save(commit=False)
|
||||
arm.untildate = form.cleaned_data["untildate"]
|
||||
arm.mbox = mb
|
||||
arm.save()
|
||||
messages.info(request, _("Auto reply message updated successfully."),
|
||||
@@ -42,6 +43,7 @@ def autoreply(request):
|
||||
mimetype="application/json")
|
||||
|
||||
form = ARmessageForm(instance=arm)
|
||||
form.fields['untildate'].initial = arm.untildate
|
||||
return _render(request, "postfix_autoreply/autoreply.html", {
|
||||
"form" : form
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user