mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
* Some javascript improvements
* Fixed little issues into the admin app see #204
This commit is contained in:
+5
-3
@@ -285,10 +285,10 @@ class AccountFormGeneralPwd(AccountFormGeneral):
|
||||
|
||||
class AccountFormMail(forms.Form, DynamicForm):
|
||||
# FIXME
|
||||
# * ajout du quota
|
||||
# * Renommage de boite ?
|
||||
|
||||
email = forms.EmailField(label=_("E-mail"), required=False)
|
||||
quota = forms.IntegerField(label=_("Quota"), required=False)
|
||||
aliases = forms.EmailField(
|
||||
label=ugettext_noop("Alias(es)"),
|
||||
required=False,
|
||||
@@ -309,6 +309,7 @@ class AccountFormMail(forms.Form, DynamicForm):
|
||||
name = "aliases_%d" % (pos + 1)
|
||||
self._create_field(forms.EmailField, name, alias.full_address)
|
||||
self.fields["email"].initial = self.mb.full_address
|
||||
self.fields["quota"].initial = self.mb.quota
|
||||
if len(args) and isinstance(args[0], QueryDict):
|
||||
self._load_from_qdict(args[0], "aliases", forms.EmailField)
|
||||
|
||||
@@ -331,7 +332,8 @@ class AccountFormMail(forms.Form, DynamicForm):
|
||||
except Mailbox.DoesNotExist:
|
||||
events.raiseEvent("CanCreate", user, "mailboxes")
|
||||
self.mb = Mailbox()
|
||||
self.mb.save_from_user(locpart, domain, account)
|
||||
self.mb.save_from_user(locpart, domain, account,
|
||||
self.cleaned_data["quota"])
|
||||
grant_access_to_object(user, self.mb, is_owner=True)
|
||||
events.raiseEvent("CreateMailbox", user, self.mb)
|
||||
else:
|
||||
@@ -339,9 +341,9 @@ class AccountFormMail(forms.Form, DynamicForm):
|
||||
if self.mb.rename_dir(domname, locpart):
|
||||
self.mb.domain = domain
|
||||
self.mb.address = locpart
|
||||
self.mb.save()
|
||||
else:
|
||||
raise AdminError(_("Failed to rename mailbox, check permissions"))
|
||||
self.mb.save(quota=self.cleaned_data["quota"])
|
||||
|
||||
account.email = self.cleaned_data["email"]
|
||||
account.save()
|
||||
|
||||
+2
-2
@@ -584,7 +584,7 @@ class Mailbox(DatesAware):
|
||||
pass
|
||||
super(Mailbox, self).save(*args, **kwargs)
|
||||
|
||||
def save_from_user(self, localpart, domain, user):
|
||||
def save_from_user(self, localpart, domain, user, quota=None):
|
||||
"""Simple save method called for automatic creations
|
||||
|
||||
:param localpart: the mailbox
|
||||
@@ -608,7 +608,7 @@ class Mailbox(DatesAware):
|
||||
self.gid = v_gid
|
||||
else:
|
||||
self.gid = pwd.getpwnam(parameters.get_admin("VIRTUAL_GID")).pw_gid
|
||||
self.quota = self.domain.quota
|
||||
self.quota = self.domain.quota if quota is None else quota
|
||||
super(Mailbox, self).save()
|
||||
|
||||
def create_from_csv(self, user, line):
|
||||
|
||||
+3
-3
@@ -93,7 +93,7 @@ def newdomain(request):
|
||||
@permission_required("admin.change_domain")
|
||||
def editdomain(request, dom_id, tplname="admin/domainform.html"):
|
||||
domain = Domain.objects.get(pk=dom_id)
|
||||
if not request.user.is_owner(domain):
|
||||
if not request.user.can_access(domain):
|
||||
raise PermDeniedException(_("You can't edit this domain"))
|
||||
|
||||
commonctx = {"title" : _("Domain editing"),
|
||||
@@ -210,7 +210,7 @@ def newdlist(request, tplname="common/generic_modal_form.html"):
|
||||
@permission_required("admin.change_alias")
|
||||
def editdlist(request, dlist_id, tplname="admin/dlistform.html"):
|
||||
dlist = Alias.objects.get(pk=dlist_id)
|
||||
if not request.user.is_owner(dlist.domain):
|
||||
if not request.user.can_access(dlist.domain):
|
||||
raise PermDeniedException(_("You do not have access to this domain"))
|
||||
commonctx = {"title" : dlist.full_address,
|
||||
"action_label" : _("Update"),
|
||||
@@ -233,7 +233,7 @@ def deldlist(request):
|
||||
selection = request.GET["selection"].split(",")
|
||||
for dlist_id in selection:
|
||||
dlist = Alias.objects.get(pk=dlist_id)
|
||||
if not request.user.is_owner(dlist.domain):
|
||||
if not request.user.can_access(dlist.domain):
|
||||
raise PermDeniedException(_("You do not have access to this domain"))
|
||||
events.raiseEvent("MailboxAliasDeleted", dlist)
|
||||
ungrant_access_to_object(dlist)
|
||||
|
||||
+6
-2
@@ -28,7 +28,9 @@ function newaccount_cb() {
|
||||
function editaccount_cb() {
|
||||
accountform_init();
|
||||
$('#submit').click(function(e) {
|
||||
simple_ajax_form_post(e, editaccount_cb);
|
||||
simple_ajax_form_post(e, {
|
||||
error_cb: editaccount_cb
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -39,7 +41,9 @@ function dlistform_cb() {
|
||||
});
|
||||
$("#id_recipients").dynamic_input();
|
||||
$(".submit").one('click', function(e) {
|
||||
simple_ajax_form_post(e, dlistform_cb);
|
||||
simple_ajax_form_post(e, {
|
||||
error_cb: dlistform_cb
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
show: function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
this.box = this.buildbox();
|
||||
this.box.modal();
|
||||
this.box.on('hidden', $.proxy(this.hidden_callback, this));
|
||||
@@ -85,6 +85,8 @@
|
||||
}
|
||||
if (data.status == "ok") {
|
||||
window.location.reload();
|
||||
} else {
|
||||
$("body").notify("error", data.respmsg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -151,10 +151,10 @@ History.prototype = {
|
||||
},
|
||||
|
||||
getparam: function(name) {
|
||||
if (!this.params.has(name)) {
|
||||
if (this.params[name] === undefined) {
|
||||
return "";
|
||||
}
|
||||
return this.params.get(name);
|
||||
return this.params[name];
|
||||
},
|
||||
|
||||
baseurl: function(value, noreset) {
|
||||
|
||||
@@ -25,8 +25,11 @@
|
||||
},
|
||||
|
||||
listen: function() {
|
||||
$(document).on("click", "tbody>tr",
|
||||
$.proxy(this.toggle_select, this));
|
||||
|
||||
$(document)
|
||||
.off("click", "tbody>tr")
|
||||
.on("click", "tbody>tr",
|
||||
$.proxy(this.toggle_select, this));
|
||||
$(document).on("keydown", "body", $.proxy(this.keydown, this));
|
||||
$(document).on("keyup", "body", $.proxy(this.keyup, this));
|
||||
},
|
||||
@@ -66,6 +69,10 @@
|
||||
this._toggle_select($tr);
|
||||
},
|
||||
|
||||
is_selected: function($row) {
|
||||
return $row.hasClass(this.options.tr_selected_class);
|
||||
},
|
||||
|
||||
current_selection: function() {
|
||||
return $("tr[class*=" + this.options.tr_selected_class + "]");
|
||||
},
|
||||
|
||||
@@ -7,7 +7,5 @@
|
||||
{% block apparea %}
|
||||
{{ table|safe }}
|
||||
{% endblock %}
|
||||
{% block footer %}
|
||||
<div id="adminfo">{% get_footer_content user selection %}</div>
|
||||
{% pagination_bar page %}
|
||||
{% endblock %}
|
||||
{% block footerleft %}<div id="adminfo">{% get_footer_content user selection %}</div>{% endblock %}
|
||||
{% block footerright %}{% pagination_bar page %}{% endblock %}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{% load libextras %}
|
||||
{% render_field form.email %}
|
||||
{% render_field form.quota %}
|
||||
{% render_fields_group form "aliases" %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends "layout_simple.html" %}
|
||||
{% extends "nlayout.html" %}
|
||||
{% block content %}
|
||||
<div class="error"><p>{{ error }}</p></div>
|
||||
<div class="alert alert-error">{{ error }}</div>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user