mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
@@ -19,6 +19,7 @@ function domainform_cb() {
|
||||
}
|
||||
}]);
|
||||
});
|
||||
$(document).trigger('domform_init');
|
||||
}
|
||||
|
||||
function simpleuser_mode() {
|
||||
|
||||
@@ -144,6 +144,13 @@ $(document).ready(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).bind('domform_init', function() {
|
||||
var checked = $('#id_spam_subject_tag2_act').attr('checked');
|
||||
if (checked && checked == 'checked') {
|
||||
$('#id_spam_subject_tag2').attr('disabled', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>""")
|
||||
url = reverse("modoboa.extensions.amavis.views.nbrequests")
|
||||
|
||||
@@ -29,18 +29,19 @@ class InlineRadioSelect(RadioSelect):
|
||||
renderer = InlineRadioRenderer
|
||||
|
||||
class DomainPolicyForm(forms.ModelForm):
|
||||
spam_subject_tag2_act = forms.BooleanField()
|
||||
|
||||
class Meta:
|
||||
model = Policy
|
||||
fields = ('bypass_virus_checks', 'bypass_spam_checks',
|
||||
'spam_tag2_level', 'spam_modifies_subj',
|
||||
'spam_tag2_level', 'spam_subject_tag2',
|
||||
'spam_kill_level', 'bypass_banned_checks')
|
||||
widgets = {
|
||||
'bypass_virus_checks' : InlineRadioSelect(),
|
||||
'bypass_spam_checks' : InlineRadioSelect(),
|
||||
'spam_tag2_level' : forms.TextInput(attrs={'class' : 'span1'}),
|
||||
'spam_modifies_subj' : InlineRadioSelect(),
|
||||
'spam_kill_level' : forms.TextInput(attrs={'class' : 'span1'}),
|
||||
'spam_subject_tag2' : forms.TextInput(attrs={'class' : 'span2'}),
|
||||
'bypass_banned_checks' : InlineRadioSelect(),
|
||||
}
|
||||
|
||||
@@ -58,11 +59,13 @@ class DomainPolicyForm(forms.ModelForm):
|
||||
|
||||
def save(self, user, commit=True):
|
||||
p = super(DomainPolicyForm, self).save(commit=False)
|
||||
for f in ['bypass_spam_checks', 'bypass_virus_checks', 'bypass_banned_checks',
|
||||
'spam_modifies_subj']:
|
||||
for f in ['bypass_spam_checks', 'bypass_virus_checks', 'bypass_banned_checks']:
|
||||
if getattr(p, f) == '':
|
||||
setattr(p, f, None)
|
||||
|
||||
if self.cleaned_data['spam_subject_tag2_act']:
|
||||
p.spam_subject_tag2 = None
|
||||
|
||||
if commit:
|
||||
p.save()
|
||||
try:
|
||||
|
||||
@@ -105,14 +105,6 @@ class Policy(models.Model):
|
||||
help_text=ugettext_lazy("Bypass banned checks or not. Choose 'default' to use global settings.")
|
||||
)
|
||||
bypass_header_checks = models.CharField(max_length=3, blank=True, null=True)
|
||||
spam_modifies_subj = models.CharField(
|
||||
ugettext_lazy("Spam marker"), default='', null=True,
|
||||
choices=(('N', ugettext_lazy('yes')),
|
||||
('Y', ugettext_lazy('no')),
|
||||
('', ugettext_lazy('default'))),
|
||||
max_length=3,
|
||||
help_text=ugettext_lazy("Modify spam subject or not. Choose 'default' to use global settings.")
|
||||
)
|
||||
virus_quarantine_to = models.CharField(max_length=192, blank=True, null=True)
|
||||
spam_quarantine_to = models.CharField(max_length=192, blank=True, null=True)
|
||||
banned_quarantine_to = models.CharField(max_length=192, blank=True, null=True)
|
||||
@@ -139,7 +131,11 @@ class Policy(models.Model):
|
||||
bad_header_admin = models.CharField(max_length=192, blank=True, null=True)
|
||||
spam_admin = models.CharField(max_length=192, blank=True, null=True)
|
||||
spam_subject_tag = models.CharField(max_length=192, blank=True, null=True)
|
||||
spam_subject_tag2 = models.CharField(max_length=192, blank=True, null=True)
|
||||
spam_subject_tag2 = models.CharField(
|
||||
ugettext_lazy("Spam marker"), default='',
|
||||
max_length=192, blank=True, null=True,
|
||||
help_text=ugettext_lazy("Modify spam subject using the specified text. Choose 'default' to use global settings.")
|
||||
)
|
||||
spam_subject_tag3 = models.CharField(max_length=192, blank=True, null=True)
|
||||
message_size_limit = models.IntegerField(null=True, blank=True)
|
||||
banned_rulenames = models.CharField(max_length=192, blank=True, null=True)
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
{{ form.spam_kill_level }} <span class="help-inline">{% trans "or more throw spam message away" %}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% render_field form.spam_modifies_subj %}
|
||||
{% render_field_with_activator form.spam_subject_tag2 _("default") %}
|
||||
{% render_field form.bypass_banned_checks %}
|
||||
|
||||
@@ -7,7 +7,7 @@ from django.contrib import messages
|
||||
from django.template import Template, Context
|
||||
from django.template.loader import render_to_string
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import ugettext as _, ugettext_lazy
|
||||
from modoboa.lib import events
|
||||
from modoboa.lib.sysutils import exec_cmd
|
||||
from modoboa.lib.webutils import static_url
|
||||
@@ -106,6 +106,13 @@ def render_field_appended(field, text):
|
||||
field=field, help_display_mode="tooltip", appended_text=text
|
||||
))
|
||||
|
||||
@register.simple_tag
|
||||
def render_field_with_activator(field, activator_label=ugettext_lazy("activate")):
|
||||
return render_to_string("common/generic_field.html", {
|
||||
"field" : field, "help_display_mode" : "tooltip", "activator" : True,
|
||||
"activator_label" : activator_label
|
||||
})
|
||||
|
||||
@register.simple_tag
|
||||
def render_and_hide_field(field):
|
||||
return render_to_string("common/generic_field.html", dict(
|
||||
|
||||
@@ -222,9 +222,22 @@ function ajax_login_redirect(xhr) {
|
||||
xhr.getResponseHeader("Location").replace(/\?.*$/, params);
|
||||
}
|
||||
|
||||
function activate_widget(e) {
|
||||
var $this = $(this);
|
||||
var widget_id = $this.attr("id").substr(0, $this.attr("id").length - 4);
|
||||
var $widget = $('#' + widget_id);
|
||||
|
||||
if ($this.attr("checked") && $this.attr("checked") == "checked") {
|
||||
$widget.attr('disabled', true);
|
||||
} else {
|
||||
$widget.attr('disabled', false);
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ajaxSuccess(function(e, xhr, settings) { ajax_login_redirect(xhr); });
|
||||
$(document).on('click', 'a[data-toggle="ajaxmodal"]', modalbox);
|
||||
$(document).on('click', 'a[data-toggle="ajaxmodal-autowidth"]', modalbox_autowidth);
|
||||
$(document).on('click', '.activator', activate_widget);
|
||||
$(".help").popover();
|
||||
});
|
||||
@@ -4,6 +4,9 @@
|
||||
<div class="controls spaced">
|
||||
{% if appended_text %}<div class="input-append">{% endif %}
|
||||
{{ field }}{% if appended_text %}<span class="add-on">{{ appended_text }}</span></div>{% endif %}{% if help_display_mode == "inline" and field.help_text %}<span class="help-inline">{{ field.help_text }}</span>{% endif %}
|
||||
{% if activator %}<label class="checkbox inline" for="id_{{ field.name }}_act">
|
||||
<input type="checkbox" class="activator" id="id_{{ field.name }}_act" name="{{ field.name }}_act" {% if field.value == None %}checked='checked'{% endif %}/>{{ activator_label }}
|
||||
</label>{% endif %}
|
||||
{% if field.errors %}<p class="help-block">{% for error in field.errors %}{{ error|safe }}{% endfor %}</p>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user