mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
@@ -22,30 +22,22 @@ class AccountFormGeneral(forms.ModelForm):
|
||||
help_text=ugettext_lazy(
|
||||
"The user's name. Must be a valid e-mail address for simple users "
|
||||
"or administrators with a mailbox."
|
||||
),
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
)
|
||||
role = forms.ChoiceField(
|
||||
label=ugettext_lazy("Role"),
|
||||
choices=[('', ugettext_lazy("Choose"))],
|
||||
help_text=ugettext_lazy("What level of permission this user will have"),
|
||||
widget=forms.Select(attrs={"class": "form-control"})
|
||||
help_text=ugettext_lazy("What level of permission this user will have")
|
||||
)
|
||||
password1 = forms.CharField(
|
||||
label=ugettext_lazy("Password"),
|
||||
widget=forms.PasswordInput(attrs={"class": "form-control"})
|
||||
label=ugettext_lazy("Password")
|
||||
)
|
||||
password2 = forms.CharField(
|
||||
label=ugettext_lazy("Confirmation"),
|
||||
widget=forms.PasswordInput(attrs={"class": "form-control"}),
|
||||
help_text=ugettext_lazy("Enter the same password as above, for verification.")
|
||||
)
|
||||
first_name= forms.CharField(
|
||||
widget=forms.TextInput(attrs={"class": "form-control"}),
|
||||
)
|
||||
last_name= forms.CharField(
|
||||
widget=forms.TextInput(attrs={"class": "form-control"}),
|
||||
)
|
||||
first_name = forms.CharField()
|
||||
last_name = forms.CharField()
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
@@ -137,7 +129,7 @@ class AccountFormGeneral(forms.ModelForm):
|
||||
|
||||
|
||||
class AccountFormMail(forms.Form, DynamicForm):
|
||||
email = forms.EmailField(label=ugettext_lazy("E-mail"), required=False, widget=forms.TextInput(attrs={"class": "form-control"}))
|
||||
email = forms.EmailField(label=ugettext_lazy("E-mail"), required=False)
|
||||
quota = forms.IntegerField(
|
||||
label=ugettext_lazy("Quota"),
|
||||
required=False,
|
||||
@@ -145,7 +137,7 @@ class AccountFormMail(forms.Form, DynamicForm):
|
||||
"use domain's default one. Leave empty to define an "
|
||||
"unlimited value (not allowed for domain "
|
||||
"administrators)."),
|
||||
widget=forms.widgets.TextInput(attrs={"class": "col-md-1 form-control"})
|
||||
widget=forms.widgets.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
quota_act = forms.BooleanField(required=False)
|
||||
aliases = forms.EmailField(
|
||||
@@ -155,8 +147,7 @@ class AccountFormMail(forms.Form, DynamicForm):
|
||||
"Alias(es) of this mailbox. Indicate only one address per input, "
|
||||
"press ENTER to add a new input. Use the '*' character to create "
|
||||
"a 'catchall' alias (ex: *@domain.tld)."
|
||||
),
|
||||
widget=forms.TextInput(attrs={"class": "form-control"})
|
||||
)
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -166,6 +157,9 @@ class AccountFormMail(forms.Form, DynamicForm):
|
||||
else:
|
||||
self.mb = None
|
||||
super(AccountFormMail, self).__init__(*args, **kwargs)
|
||||
self.field_widths = {
|
||||
"quota": 3
|
||||
}
|
||||
self.extra_fields = []
|
||||
for fname, field in events.raiseQueryEvent('ExtraFormFields', 'mailform', self.mb):
|
||||
self.fields[fname] = field
|
||||
@@ -332,7 +326,9 @@ class AccountPermissionsForm(forms.Form, DynamicForm):
|
||||
self._load_from_qdict(args[0], "domains", DomainNameField)
|
||||
|
||||
def save(self):
|
||||
current_domains = [dom.name for dom in Domain.objects.get_for_admin(self.account)]
|
||||
current_domains = [
|
||||
dom.name for dom in Domain.objects.get_for_admin(self.account)
|
||||
]
|
||||
for name, value in self.cleaned_data.items():
|
||||
if not name.startswith("domains"):
|
||||
continue
|
||||
|
||||
@@ -183,7 +183,9 @@ class DomainFormOptions(forms.Form):
|
||||
create_dom_admin = YesNoField(
|
||||
label=ugettext_lazy("Create a domain administrator"),
|
||||
initial="no",
|
||||
help_text=ugettext_lazy("Automatically create an administrator for this domain")
|
||||
help_text=ugettext_lazy(
|
||||
"Automatically create an administrator for this domain"
|
||||
)
|
||||
)
|
||||
|
||||
dom_admin_username = forms.CharField(
|
||||
@@ -193,14 +195,15 @@ class DomainFormOptions(forms.Form):
|
||||
"The administrator's name. Don't include the domain's name here, "
|
||||
"it will be automatically appended."
|
||||
),
|
||||
widget=forms.widgets.TextInput(attrs={"class": "form-control input-small"}),
|
||||
required=False
|
||||
)
|
||||
|
||||
create_aliases = YesNoField(
|
||||
label=ugettext_lazy("Create aliases"),
|
||||
initial="yes",
|
||||
help_text=ugettext_lazy("Automatically create standard aliases for this domain"),
|
||||
help_text=ugettext_lazy(
|
||||
"Automatically create standard aliases for this domain"
|
||||
),
|
||||
required=False
|
||||
)
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from modoboa.extensions.amavis.models import Policy, Users
|
||||
|
||||
|
||||
class DomainPolicyForm(forms.ModelForm):
|
||||
|
||||
spam_subject_tag2_act = forms.BooleanField()
|
||||
|
||||
class Meta:
|
||||
@@ -15,9 +16,12 @@ class DomainPolicyForm(forms.ModelForm):
|
||||
widgets = {
|
||||
'bypass_virus_checks': InlineRadioSelect(),
|
||||
'bypass_spam_checks': InlineRadioSelect(),
|
||||
'spam_tag2_level': forms.TextInput(attrs={'class': 'col-md-1 form-control'}),
|
||||
'spam_kill_level': forms.TextInput(attrs={'class': 'col-md-1 form-control'}),
|
||||
'spam_subject_tag2': forms.TextInput(attrs={'class': 'col-md-2 form-control'}),
|
||||
'spam_tag2_level': forms.TextInput(
|
||||
attrs={'class': 'form-control'}),
|
||||
'spam_kill_level': forms.TextInput(
|
||||
attrs={'class': 'form-control'}),
|
||||
'spam_subject_tag2': forms.TextInput(
|
||||
attrs={'class': 'form-control'}),
|
||||
'bypass_banned_checks': InlineRadioSelect(),
|
||||
}
|
||||
|
||||
@@ -25,13 +29,14 @@ class DomainPolicyForm(forms.ModelForm):
|
||||
if "instance" in kwargs:
|
||||
self.domain = kwargs["instance"]
|
||||
try:
|
||||
policy = Users.objects.get(email="@%s" % self.domain.name).policy
|
||||
policy = Users.objects.get(
|
||||
email="@%s" % self.domain.name).policy
|
||||
kwargs["instance"] = policy
|
||||
except (Users.DoesNotExist, Policy.DoesNotExist):
|
||||
del kwargs["instance"]
|
||||
super(DomainPolicyForm, self).__init__(*args, **kwargs)
|
||||
for f in self.fields.keys():
|
||||
self.fields[f].required = False
|
||||
for field in self.fields.keys():
|
||||
self.fields[field].required = False
|
||||
|
||||
def save(self, user, commit=True):
|
||||
policy = super(DomainPolicyForm, self).save(commit=False)
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
{% load i18n form_tags %}
|
||||
{% render_field form.bypass_virus_checks %}
|
||||
{% render_field form.bypass_spam_checks %}
|
||||
<div class="input-group">
|
||||
<label class="control-label col-lg-1 col-md-2 col-sm-3">{% trans "Thresholds" %}</label>
|
||||
<div class="col-lg-11 col-md-10 col-sm-9">
|
||||
{{ form.spam_tag2_level }} <span class="help-block pull-right">{% trans "or more is spam" %}</span><br>
|
||||
{{ form.spam_kill_level }} <span class="help-block pull-right">{% trans "or more throw spam message away" %}</span>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-4 col-md-4 col-sm-4">{% trans "Thresholds" %}</label>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
{{ form.spam_tag2_level }}
|
||||
</div>
|
||||
<span class="help-block">{% trans "or more is spam" %}</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-4 col-lg-2 col-md-2 col-sm-2">
|
||||
{{ form.spam_kill_level }}
|
||||
</div>
|
||||
<span class="help-block">{% trans "or more throw spam message away" %}</span>
|
||||
</div>
|
||||
{% render_field_with_activator form.spam_subject_tag2 _("default") %}
|
||||
{% render_field form.bypass_banned_checks %}
|
||||
|
||||
@@ -19,21 +19,21 @@ class RelayDomainFormGeneral(forms.ModelForm, DynamicForm):
|
||||
help_text=ugettext_lazy(
|
||||
"Alias(es) of this relay domain. Indicate only one name per input"
|
||||
", press ENTER to add a new input."
|
||||
),
|
||||
widget=forms.TextInput(attrs={'class': 'form-control'})
|
||||
)
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = RelayDomain
|
||||
exclude = ['dates']
|
||||
widgets = {
|
||||
'service': forms.Select(attrs={'class': 'col-mg-2 form-control'}),
|
||||
'target_host': forms.TextInput(attrs={'class': 'form-control'}),
|
||||
'name': forms.TextInput(attrs={'class': 'form-control'})
|
||||
"service": forms.Select(attrs={"class": "form-control"})
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RelayDomainFormGeneral, self).__init__(*args, **kwargs)
|
||||
self.field_widths = {
|
||||
"service": 3
|
||||
}
|
||||
if args and isinstance(args[0], QueryDict):
|
||||
self._load_from_qdict(args[0], "aliases", DomainNameField)
|
||||
elif 'instance' in kwargs:
|
||||
|
||||
+3
-1
@@ -1,2 +1,4 @@
|
||||
{% extends "common/generic_field.html" %}{% load i18n %}
|
||||
{% block extra_controls %}<a id="btnscan" class="btn btn-success pull-right" style="margin-top: 2px" href="{% url 'modoboa.extensions.postfix_relay_domains.views.scan_for_services' %}">{% trans "Scan" %}</a>{% endblock %}
|
||||
{% block extra_controls %}
|
||||
<a id="btnscan" class="btn btn-success" style="margin-top: 2px" href="{% url 'modoboa.extensions.postfix_relay_domains.views.scan_for_services' %}">{% trans "Scan" %}</a>
|
||||
{% endblock %}
|
||||
|
||||
@@ -58,6 +58,7 @@ def render_field_appended(field, text):
|
||||
|
||||
@register.simple_tag
|
||||
def render_field_with_activator(field, activator_label=ugettext_lazy("activate")):
|
||||
configure_field_classes(field)
|
||||
return render_to_string("common/generic_field.html", {
|
||||
"field": field, "help_display_mode": "tooltip", "activator": True,
|
||||
"activator_label": activator_label, "deactivate_if_empty": True
|
||||
@@ -73,7 +74,7 @@ def render_and_hide_field(field):
|
||||
|
||||
@register.simple_tag
|
||||
def render_fields_group(form, pattern):
|
||||
first = forms.BoundField(form, form.fields[pattern], pattern)
|
||||
first = forms.forms.BoundField(form, form.fields[pattern], pattern)
|
||||
configure_field_classes(first)
|
||||
label = first.label
|
||||
group = [first]
|
||||
@@ -83,7 +84,7 @@ def render_fields_group(form, pattern):
|
||||
fname = "%s_%d" % (pattern, cpt)
|
||||
if not fname in form.fields:
|
||||
break
|
||||
bfield = forms.BoundField(form, form.fields[fname], fname)
|
||||
bfield = forms.forms.BoundField(form, form.fields[fname], fname)
|
||||
if len(bfield.errors):
|
||||
haserror = True
|
||||
configure_field_classes(bfield)
|
||||
|
||||
@@ -19,13 +19,12 @@
|
||||
buildcheckboxes: function() {
|
||||
var result = "";
|
||||
|
||||
if (!this.options.checkboxes) {
|
||||
if (!this.options.checkboxes || !this.options.checkboxes.length) {
|
||||
return "";
|
||||
}
|
||||
result = '<form class="form-inline">';
|
||||
$.each(this.options.checkboxes, function(key, val) {
|
||||
result += "<label class='checkbox'><input type='checkbox' name='" + key + "' value='' />";
|
||||
result += val + "</label>";
|
||||
result += "<label class='checkbox'><input type='checkbox' name='{0}' value='' />{1}</label>".format(key, val);
|
||||
});
|
||||
result += '</form>';
|
||||
return result;
|
||||
@@ -34,55 +33,56 @@
|
||||
buildbox: function() {
|
||||
var box = $('<div />', {
|
||||
id: "confirmbox",
|
||||
'class': "modal"
|
||||
'class': "modal fade"
|
||||
});
|
||||
var question = (typeof this.options.question == 'function')
|
||||
? this.options.question.apply(this) : this.options.question;
|
||||
var question = (typeof this.options.question == 'function') ?
|
||||
this.options.question.apply(this) : this.options.question;
|
||||
var checkboxes = this.buildcheckboxes();
|
||||
var body = "";
|
||||
|
||||
box.append($('<div class="modal-body">'
|
||||
+ '<h4>' + question + '</h4>'));
|
||||
var $container = $("<div />", {"class" : "container-fluid"});
|
||||
box.append($container);
|
||||
if (this.options.warning) {
|
||||
$container.append($("<div />", {"class" : "row"})
|
||||
.append($("<div />", {
|
||||
"class": "alert alert-danger",
|
||||
html: "<h4>" + gettext("Warning") + "</h4>" + this.options.warning
|
||||
}))
|
||||
);
|
||||
body += '<div class="alert alert-danger"><h4>{0}</h4>{1}</div>'.format(gettext("Warning"), this.options.warning);
|
||||
}
|
||||
if (checkboxes !== "") {
|
||||
body += "<p>{0}</p>".format(checkboxes);
|
||||
}
|
||||
|
||||
$container.append('<p>' + this.buildcheckboxes() + '</p>');
|
||||
box.append("</div>");
|
||||
var content = '<div class="modal-dialog"><div class="modal-content">';
|
||||
var title_patten = '<div class="{0}"><h3 class="modal-title">{1}</h3></div>';
|
||||
|
||||
var footer = $('<div class="modal-footer" />');
|
||||
var cancel_btn = $('<a href="#" class="btn">' + gettext("Cancel") + "</a>");
|
||||
var ok_btn = $('<a href="#" class="btn btn-primary">Ok</a>');
|
||||
if (body !== "") {
|
||||
console.log(body);
|
||||
content += title_patten.format("modal-header", question);
|
||||
content += '<div class="modal-body">{0}</div>'.format(body);
|
||||
} else {
|
||||
content += title_patten.format("modal-body", question);
|
||||
}
|
||||
content += '<div class="modal-footer"><a href="#" class="btn btn-primary">Ok</a><a href="#" class="btn btn-default">{0}</a></div>'.format(gettext("Cancel"));
|
||||
|
||||
ok_btn.click(function(evt) {
|
||||
box.append($(content));
|
||||
|
||||
box.find(".btn-primary").click(function(evt) {
|
||||
evt.preventDefault();
|
||||
box.data('result', true);
|
||||
box.modal('hide');
|
||||
});
|
||||
|
||||
cancel_btn.click(function(evt) {
|
||||
box.find(".btn-default").click(function(evt) {
|
||||
evt.preventDefault();
|
||||
box.modal('hide');
|
||||
});
|
||||
|
||||
footer.append(ok_btn, cancel_btn);
|
||||
box.append(footer);
|
||||
return box;
|
||||
},
|
||||
|
||||
hidden_callback: function() {
|
||||
if (this.box.data('result') == undefined) {
|
||||
if (this.box.data('result') === undefined) {
|
||||
return;
|
||||
}
|
||||
var params = "";
|
||||
|
||||
$('input[type=checkbox]:checked').each(function() {
|
||||
if (params != "") {
|
||||
if (params !== "") {
|
||||
params += "&";
|
||||
}
|
||||
params += $(this).attr("name") + "=true";
|
||||
|
||||
@@ -316,6 +316,18 @@ function default_ajax_error_handler(event, jqxhr, settings) {
|
||||
$('body').notify('error', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* An equivalent of python .format() method.
|
||||
*/
|
||||
String.prototype.format = function() {
|
||||
var args = arguments;
|
||||
return this.replace(/\{\{|\}\}|\{(\d+)\}/g, function (m, n) {
|
||||
if (m == "{{") { return "{"; }
|
||||
if (m == "}}") { return "}"; }
|
||||
return args[n];
|
||||
});
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ajaxSuccess(function(e, xhr, settings) { ajax_login_redirect(xhr); });
|
||||
$(document).ajaxError(default_ajax_error_handler);
|
||||
|
||||
@@ -26,21 +26,7 @@
|
||||
<span class="help-block pull-right">{{ field.help_text }}</span>
|
||||
{% endif %}
|
||||
{% if inline_message %}
|
||||
<span class="help-block pull-right">{{ inline_message }}</span>
|
||||
{% endif %}
|
||||
{% if activator %}
|
||||
<div class="checkbox">
|
||||
<label class="checkbox-inline" for="id_{{ field.name }}_act">
|
||||
<input type="checkbox" class="activator" id="id_{{ field.name }}_act" name="{{ field.name }}_act"
|
||||
{% if activator_value %}checked='checked'
|
||||
{% else %}
|
||||
{% if deactivate_if_empty and field.value == None %}
|
||||
checked='checked'
|
||||
{% endif %}
|
||||
{% endif %}/>
|
||||
{{ activator_label }}
|
||||
</label>
|
||||
</div>
|
||||
<span class="">{{ inline_message }}</span>
|
||||
{% endif %}
|
||||
{% if field.errors %}
|
||||
<p class="help-block">
|
||||
@@ -49,7 +35,24 @@
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% block extra_controls %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
||||
{% if activator %}
|
||||
<div class="checkbox">
|
||||
<label for="id_{{ field.name }}_act">
|
||||
<input type="checkbox" class="activator" id="id_{{ field.name }}_act" name="{{ field.name }}_act"
|
||||
{% if activator_value %}checked='checked'
|
||||
{% else %}
|
||||
{% if deactivate_if_empty and field.value == None %}
|
||||
checked='checked'
|
||||
{% endif %}
|
||||
{% endif %}/>
|
||||
{{ activator_label }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% block extra_controls %}
|
||||
{% endblock %}
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user