diff --git a/admin/tables.py b/admin/tables.py index b8c9cc304..301e1ea5e 100644 --- a/admin/tables.py +++ b/admin/tables.py @@ -7,10 +7,11 @@ class DomainsTable(tables.Table): tableid = "objects_table" idkey = "id" - name = tables.Column("name", label=ugettext_noop("Name")) - creation = tables.Column("creation", label=ugettext_noop("Created"), width="160px") - modified = tables.Column("last_modification", label=ugettext_noop("Last modified"), - width="160px") + name = tables.LinkColumn( + "name", label=ugettext_noop("Name"), + urlpattern="modoboa.admin.views.editdomain", + title=_("Edit domain"), modal=True, modalcb="domainform_cb" + ) domaliases = tables.Column("domainalias_count", label=ugettext_noop("Domain aliases"), width="100px", align="center") mboxes = tables.Column("mailbox_count", label=ugettext_noop("Mailboxes"), @@ -24,8 +25,7 @@ class DomainsTable(tables.Table): actions = tables.ActionColumn("actions", label=ugettext_noop("Actions"), width="70px", align="center", defvalue=domain_actions) - cols_order = ["name", "creation", "modified", - "domaliases", "mboxes", "mbaliases", + cols_order = ["name", "domaliases", "mboxes", "mbaliases", "quota", "actions"] def __init__(self, request, doms): @@ -52,38 +52,6 @@ class ExtensionsTable(tables.Table): cols_order = ["selection", "name", "version", "descr"] -class AccountsTable(tables.Table): - idkey = "id" - username = tables.Column("username", label=ugettext_noop("User name")) - first_name = tables.Column("first_name", label=ugettext_noop("First name")) - last_name = tables.Column("last_name", label=ugettext_noop("Last name")) - date_joined = tables.Column("date_joined", label=ugettext_noop("Defined")) - enabled = tables.Column("is_active", label=gender("Enabled", "m"), width="10%") - role = tables.Column("group", label=ugettext_noop("Role")) - actions = tables.ActionColumn("actions", label=ugettext_noop("Actions"), - width="70px", align="center", - defvalue=account_actions) - - cols_order = ["username", "first_name", "last_name", "date_joined", - "role", "actions"] - - def __init__(self, request, users): - super(AccountsTable, self).__init__(request) - self.populate(self._rows_from_model(users)) - - def parse_is_active(self, value): - return _("yes") if value else _("no") - - def parse_group(self, value): - if value == "SimpleUsers": - return "U" - return value[:1] - - def row_class(self, request, obj): - if not obj.is_active: - return "muted" - return "" - class IdentitiesTable(tables.Table): idkey = "id" identity = tables.Column("identity", label=ugettext_noop("Email/Username")) diff --git a/admin/templatetags/admin_extras.py b/admin/templatetags/admin_extras.py index 439159915..933e10090 100644 --- a/admin/templatetags/admin_extras.py +++ b/admin/templatetags/admin_extras.py @@ -115,15 +115,9 @@ def identities_menu(user): @register.simple_tag def domain_actions(user, domid): actions = [ - {"name" : "editdomain", - "url" : reverse(admin.views.editdomain, args=[domid]), - "img" : "icon-edit", - "title" : _("Edit domain"), - "modal" : True, - "modalcb" : "domainform_cb"}, {"name" : "deldomain", "url" : reverse(admin.views.deldomain) + "?selection=%s" % domid, - "img" : "icon-remove"}, + "img" : "icon-trash"}, ] return render_actions(actions) @@ -139,7 +133,7 @@ def account_actions(user, accountid): "title" : _("Edit account")}, {"name" : "delaccount", "url" : reverse(admin.views.delaccount) + "?selection=%s" % accountid, - "img" : "icon-remove", + "img" : "icon-trash", "title" : _("Delete this account")}, ] return render_actions(actions) @@ -158,7 +152,7 @@ def identity_actions(user, iid): "title" : _("Edit distribution list")}, {"name" : "deldlist", "url" : reverse(admin.views.deldlist) + "?selection=%s" % objid, - "img" : "icon-remove", + "img" : "icon-trash", "title" : _("Delete this distribution list")}, ] return render_actions(actions) diff --git a/admin/tests.py b/admin/tests.py index 562e4acbb..101df80fa 100644 --- a/admin/tests.py +++ b/admin/tests.py @@ -7,6 +7,7 @@ Liste des tests effectués Permissions ----------- + * Vérifier qu'un admin de domaine qui modifie son propre compte laisse le rôle intact diff --git a/lib/tables.py b/lib/tables.py index 1d07fbda1..a4c931572 100644 --- a/lib/tables.py +++ b/lib/tables.py @@ -10,9 +10,11 @@ output (using standard tags like and co.). """ import inspect import lxml +from django.core.urlresolvers import reverse from django.utils.translation import ugettext as _ from django.template import Template, RequestContext, Context from django.template.loader import render_to_string +from templatetags.libextras import render_link class Column: """Simple column representation @@ -70,6 +72,12 @@ class ActionColumn(Column): def render(self, fct, user, rowid): return fct(user, rowid) +class LinkColumn(Column): + def render(self, rowid, value): + linkdef = dict(url=reverse(self.urlpattern, args=[rowid]), label=value, + modal=self.modal, modalcb=self.modalcb) + return render_link(linkdef) + class Table(object): tableid = "" @@ -133,6 +141,9 @@ class Table(object): elif isinstance(c, ActionColumn): newcol["value"] = c.render(c.defvalue, self.request.user, nrow["id"]) newcol["safe"] = True + elif isinstance(c, LinkColumn): + newcol["value"] = c.render(nrow["id"], row[c.name]) + newcol["safe"] = True elif row.has_key(c.name): if "class" in row.keys(): newcol["cssclass"] += newcol["cssclass"] != "" \ diff --git a/static/js/utils.js b/static/js/utils.js index db5b2c617..b0b0eb360 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -19,7 +19,6 @@ function modalbox(e, css, defhref, defcb) { return; } var $div = $('') - .modal() .one('shown', function() { if (modalcb != undefined) { if (typeof modalcb === "function") { @@ -31,7 +30,8 @@ function modalbox(e, css, defhref, defcb) { }) .on('hidden', function() { $("#modalbox").remove(); - }); + }) + .modal(); if (css != undefined) { $div.css(css);