Many webmail improvements.

This commit is contained in:
tonio
2010-01-21 10:18:22 +01:00
parent bf971301b6
commit 61d5aa2554
18 changed files with 268 additions and 126 deletions
+9 -3
View File
@@ -14,7 +14,8 @@ class MBconnector(object):
class Page(object):
def __init__(self, pageid, id_start, id_stop, items,
items_per_page, has_previous, has_next):
items_per_page, has_previous, has_next,
baseurl=None):
self.pageid = pageid
self.id_start = id_start
self.id_stop = id_stop
@@ -22,6 +23,7 @@ class Page(object):
self.items_per_page = items_per_page
self.has_previous = has_previous
self.has_next = has_next
self.baseurl = baseurl
def previous_page(self):
if not self.has_previous:
@@ -45,6 +47,7 @@ class Paginator(object):
def __init__(self, total, elems_per_page):
self.total = total
self.elems_per_page = elems_per_page
self.baseurl = None
def _indexes(self, page):
id_start = self.elems_per_page * page + 1
@@ -65,8 +68,11 @@ class Paginator(object):
id_stop = self.total
else:
return None
return Page(page, id_start, id_stop, self.total,
self.elems_per_page, has_previous, has_next)
p = Page(page, id_start, id_stop, self.total,
self.elems_per_page, has_previous, has_next)
if self.baseurl:
p.baseurl = self.baseurl
return p
class EmailListing:
def __init__(self, folder=None, elems_per_page=40, **kwargs):
+3 -1
View File
@@ -13,7 +13,9 @@ events = ["CreateDomain",
"ModifyMailbox",
"UserMenuDisplay",
"AdminMenuDisplay"]
"AdminMenuDisplay",
"UserLogin"]
callbacks = {}
+21 -6
View File
@@ -24,6 +24,13 @@ class SelectionColumn(Column):
return "<input type='checkbox' name='%s' value='%s' />" \
% (self.name, value)
class ImgColumn(Column):
def __str__(self):
return ""
def render(self, value):
return "<img src='%s' />" % value
class Table(object):
def __init__(self, rows={}):
self.columns = []
@@ -41,16 +48,24 @@ class Table(object):
if isinstance(c, SelectionColumn):
nrow["cols"] += [{"value" : c.render(row[self.idkey]), "safe" : True}]
continue
if isinstance(c, ImgColumn):
key = "img_%s" % c.name
if key in row.keys():
nrow["cols"] += [{"value" : c.render(row[key]), "safe" : True}]
else:
nrow["cols"] += ["."]
continue
if row.has_key(c.name):
try:
nrow["cols"] += [{"value" : getattr(self, "parse_%s" % c.name)(row[c.name])}]
except AttributeError:
nrow["cols"] += [{"value" : row[c.name]}]
if "class" in row.keys():
cssclass = row["class"]
else:
cssclass = ""
nrow["cols"] += [{"value" : self.parse(c.name, row[c.name]),
"class" : cssclass}]
self.rows += [nrow]
def render(self, request):
return render_to_string("common/tables.html", {
"table" : self
})