mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
@@ -202,7 +202,7 @@ class GeneralParametersForm(parameters.AdminParametersForm):
|
||||
tpl = self.cleaned_data["ldap_user_dn_template"]
|
||||
try:
|
||||
test = tpl % {"user": "toto"}
|
||||
except ValueError:
|
||||
except (KeyError, ValueError):
|
||||
raise forms.ValidationError(_("Invalid syntax"))
|
||||
return tpl
|
||||
|
||||
|
||||
@@ -39,3 +39,16 @@ Best regards,
|
||||
),
|
||||
widget=forms.widgets.Textarea
|
||||
)
|
||||
|
||||
def clean_default_content(self):
|
||||
"""Check if the provided value is valid.
|
||||
|
||||
Must be a valid format string which will be used with the %
|
||||
operator.
|
||||
"""
|
||||
tpl = self.cleaned_data["default_content"]
|
||||
try:
|
||||
test = tpl % {"name": "Antoine Nguyen"}
|
||||
except (KeyError, ValueError):
|
||||
raise forms.ValidationError(ugettext_lazy("Invalid syntax"))
|
||||
return tpl
|
||||
|
||||
@@ -138,7 +138,8 @@ def save_extra_mailform_fields(form_name, mailbox, values):
|
||||
else:
|
||||
arm = ARmessage(mbox=mailbox)
|
||||
arm.subject = parameters.get_admin("DEFAULT_SUBJECT")
|
||||
arm.content = parameters.get_admin("DEFAULT_CONTENT")
|
||||
arm.content = parameters.get_admin("DEFAULT_CONTENT") \
|
||||
% {'name': mailbox.user.fullname}
|
||||
arm.fromdate = timezone.now()
|
||||
arm.enabled = True if values['autoreply'] == 'yes' else False
|
||||
arm.save()
|
||||
|
||||
Reference in New Issue
Block a user