* Using 'icon-trash' to represent 'delete' actions (fixes #210)

* A simple click on a domain name opens the edit box (fixes #209)
* No more creation and modification dates in the listing (fixes #211)
* Fixed an issue with modal boxes
This commit is contained in:
Antoine Nguyen
2012-04-06 09:48:59 +02:00
parent 4e78f6b01a
commit 67ec55beac
5 changed files with 23 additions and 49 deletions
+6 -38
View File
@@ -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"))
+3 -9
View File
@@ -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)
+1
View File
@@ -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
+11
View File
@@ -10,9 +10,11 @@ output (using standard tags like <table> 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"] != "" \
+2 -2
View File
@@ -19,7 +19,6 @@ function modalbox(e, css, defhref, defcb) {
return;
}
var $div = $('<div id="modalbox" class="modal" >' + data + '</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);