mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
@@ -6,7 +6,7 @@ from modoboa.lib.exceptions import PermDeniedException, Conflict, NotFound
|
||||
from modoboa.lib.permissions import get_account_roles
|
||||
from modoboa.lib.emailutils import split_mailbox
|
||||
from modoboa.lib.formutils import (
|
||||
DomainNameField, DynamicForm, TabForms, YesNoField
|
||||
DomainNameField, DynamicForm, TabForms
|
||||
)
|
||||
from modoboa.core.models import User
|
||||
from modoboa.extensions.admin.models import (
|
||||
|
||||
@@ -268,6 +268,7 @@ var Identities = function(options) {
|
||||
Identities.prototype = {
|
||||
initialize: function(options) {
|
||||
Admin.prototype.initialize.call(this, options);
|
||||
this.domain_list = [];
|
||||
this.register_tag_handler("idt", this.generic_tag_handler);
|
||||
this.register_tag_handler("grp", this.grp_tag_handler);
|
||||
},
|
||||
@@ -320,10 +321,29 @@ Identities.prototype = {
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieve a list of domain from the server.
|
||||
*
|
||||
* @this Identities
|
||||
* @return {Array} a list of domain names
|
||||
*/
|
||||
get_domain_list: function() {
|
||||
if (!this.domain_list.length) {
|
||||
$.ajax({
|
||||
url: this.options.domain_list_url,
|
||||
dataType: "json",
|
||||
async: false
|
||||
}).done($.proxy(function(data) {
|
||||
this.domain_list = data;
|
||||
}, this));
|
||||
}
|
||||
return this.domain_list;
|
||||
},
|
||||
|
||||
simpleuser_mode: function() {
|
||||
$("#id_username").autocompleter({
|
||||
from_character: "@",
|
||||
choices: get_domains_list
|
||||
choices: $.proxy(this.get_domain_list, this)
|
||||
});
|
||||
$("#id_email").addClass("disabled")
|
||||
.attr("readonly", "")
|
||||
@@ -356,11 +376,11 @@ Identities.prototype = {
|
||||
mailform_init: function() {
|
||||
$("#id_aliases").autocompleter({
|
||||
from_character: "@",
|
||||
choices: get_domains_list
|
||||
choices: $.proxy(this.get_domain_list, this)
|
||||
}).dynamic_input();
|
||||
$("#id_email").autocompleter({
|
||||
from_character: "@",
|
||||
choices: get_domains_list
|
||||
choices: $.proxy(this.get_domain_list, this)
|
||||
});
|
||||
if ($("#id_role").length) {
|
||||
$("#id_role").trigger("change");
|
||||
@@ -369,7 +389,7 @@ Identities.prototype = {
|
||||
}
|
||||
$("#id_domains")
|
||||
.autocompleter({
|
||||
choices: get_domains_list
|
||||
choices: $.proxy(this.get_domain_list, this)
|
||||
})
|
||||
.dynamic_input();
|
||||
activate_widget.call($("#id_quota_act"));
|
||||
@@ -412,7 +432,7 @@ Identities.prototype = {
|
||||
aliasform_cb: function() {
|
||||
$("#id_email").autocompleter({
|
||||
from_character: "@",
|
||||
choices: get_domains_list
|
||||
choices: $.proxy(this.get_domain_list, this)
|
||||
});
|
||||
$("#id_recipients").dynamic_input();
|
||||
$(".submit").on('click', $.proxy(function(e) {
|
||||
|
||||
@@ -4,20 +4,11 @@
|
||||
{{ block.super }}
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/autocompleter.js"></script>
|
||||
<script type="text/javascript">
|
||||
function get_domains_list(container) {
|
||||
$.getJSON("{% url 'modoboa.extensions.admin.views.domain.domains_list' %}", function(data) {
|
||||
container.value = data;
|
||||
});
|
||||
}
|
||||
|
||||
function get_account_list(container) {
|
||||
$.getJSON("{% url 'modoboa.extensions.admin.views.identity.accounts_list' %}", function(data) {
|
||||
container.value = data;
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
admin = new Identities();
|
||||
admin = new Identities({
|
||||
domain_list_url: "{% url 'modoboa.extensions.admin.views.domain.domains_list' %}",
|
||||
load_page_url: "{% url 'modoboa.extensions.admin.views.identity._identities' %}"
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% extra_static_content "identities" user %}
|
||||
|
||||
@@ -4,7 +4,6 @@ from django.utils.translation import ugettext as _
|
||||
from django.db import IntegrityError
|
||||
from modoboa.core.models import ObjectAccess, User
|
||||
from modoboa.lib import events
|
||||
from modoboa.lib.exceptions import ModoboaException
|
||||
|
||||
|
||||
def get_account_roles(user, account=None):
|
||||
@@ -19,7 +18,7 @@ def get_account_roles(user, account=None):
|
||||
"""
|
||||
std_roles = [("SimpleUsers", _("Simple user"))]
|
||||
if user.is_superuser:
|
||||
std_roles += [("SuperAdmins", _("Super administrator"))]
|
||||
std_roles += [("SuperAdmins", _("Super administrator"))]
|
||||
filters = events.raiseQueryEvent(
|
||||
'UserCanSetRole', user, 'DomainAdmins', account
|
||||
)
|
||||
|
||||
@@ -9,13 +9,10 @@
|
||||
initialize: function(element, options) {
|
||||
this.$element = $(element);
|
||||
this.options = $.extend({}, $.fn.autocompleter.defaults, options);
|
||||
this.choices = {
|
||||
value: null
|
||||
};
|
||||
if (typeof this.options.choices === "function") {
|
||||
this.options.choices(this.choices);
|
||||
this.choices = this.options.choices();
|
||||
} else {
|
||||
this.choices.value = this.options.choices();
|
||||
this.choices = this.options.choices;
|
||||
}
|
||||
this.$menu =
|
||||
$('<ul class="dropdown-menu autocompleter" data-toggle="dropdown" />');
|
||||
@@ -54,7 +51,7 @@
|
||||
var exp = new RegExp("^" + pattern);
|
||||
|
||||
this.$menu.empty();
|
||||
$.each(this.choices.value, $.proxy(function(index, value) {
|
||||
$.each(this.choices, $.proxy(function(index, value) {
|
||||
if (exp.test(value)) {
|
||||
this.$menu.append($('<li><a href="#" name="' + value
|
||||
+ '">' + value + '</a></li>'));
|
||||
@@ -148,7 +145,7 @@
|
||||
evt.preventDefault();
|
||||
this.activate_next();
|
||||
break;
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
keyup: function(evt) {
|
||||
@@ -194,4 +191,4 @@
|
||||
'empty_choice' : null
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery);
|
||||
|
||||
Reference in New Issue
Block a user