From 3b800271fb6d1019439c02d467a016d5330ca28c Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Fri, 11 Jan 2013 17:07:48 +0100 Subject: [PATCH] New tags to simplify the reading of the identities listing. see #319 --- modoboa/admin/models.py | 15 +++++++++++++++ modoboa/admin/tables.py | 3 ++- modoboa/lib/tables.py | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/modoboa/admin/models.py b/modoboa/admin/models.py index e9ccc6bd2..5e4b0089b 100644 --- a/modoboa/admin/models.py +++ b/modoboa/admin/models.py @@ -176,6 +176,12 @@ class User(DUser): val1 = raw_value return constant_time_compare(val1, val2) + @property + def metainfo(self): + ret = '%s' % _("account") + ret += ' %s' % self.group + return ret + @property def has_mailbox(self): return len(self.mailbox_set.all()) != 0 @@ -760,6 +766,15 @@ class Alias(DatesAware): return "%s, ..." % rcpts[0] return rcpts[0] + @property + def metainfo(self): + cpt = len(self.mboxes.all()) + if cpt: + label = _("alias") if cpt == 1 else _("distribution list") + else: + label = _("forward") + return '%s' % label + def save(self, int_rcpts, ext_rcpts, *args, **kwargs): if len(ext_rcpts): self.extmboxes = ",".join(ext_rcpts) diff --git a/modoboa/admin/tables.py b/modoboa/admin/tables.py index 85e6844a2..dd0e6e88e 100644 --- a/modoboa/admin/tables.py +++ b/modoboa/admin/tables.py @@ -50,6 +50,7 @@ class ExtensionsTable(tables.Table): class IdentitiesTable(tables.Table): idkey = "id" styles = "table" + metainfo = tables.Column("metainfo", label=ugettext_lazy("Tags"), safe=True) identity = tables.LinkColumn( "identity", label=ugettext_lazy("Email/Username"), modal=True, @@ -61,7 +62,7 @@ class IdentitiesTable(tables.Table): actions = tables.ActionColumn("actions", label=ugettext_lazy("Actions"), defvalue=identity_actions) - cols_order = ["identity", "name_or_rcpt", "actions"] + cols_order = ["identity", "name_or_rcpt", "metainfo", "actions"] def __init__(self, request, identities): super(IdentitiesTable, self).__init__(request) diff --git a/modoboa/lib/tables.py b/modoboa/lib/tables.py index 07118aab7..1ba254f49 100644 --- a/modoboa/lib/tables.py +++ b/modoboa/lib/tables.py @@ -30,7 +30,7 @@ class Column: label = getattr(self, "label") except AttributeError: label = getattr(self, "name") - return _(label) + return label.encode("utf-8") class SelectionColumn(Column): """Specific column: selection