Author: justi9
Date: 2007-11-27 11:44:33 -0500 (Tue, 27 Nov 2007)
New Revision: 1371
Modified:
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/widgets.py
mgmt/cumin/python/cumin/widgets.strings
Log:
Implements a paginator and deploys it on the broker list.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2007-11-27 16:26:44 UTC (rev 1370)
+++ mgmt/cumin/python/cumin/broker.py 2007-11-27 16:44:33 UTC (rev 1371)
@@ -81,6 +81,10 @@
self.paginator = self.BrokerPaginator(app, "page")
self.add_child(self.paginator)
+ def get_items(self, session, model):
+ start, end = self.paginator.get_bounds(session)
+ return model.sys.brokers[start:end]
+
def do_process(self, session, model):
if self.submit.get(session):
self.submit.set(session, False)
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-11-27 16:26:44 UTC (rev 1370)
+++ mgmt/cumin/python/cumin/widgets.py 2007-11-27 16:44:33 UTC (rev 1371)
@@ -271,14 +271,24 @@
self.param.set_default(0)
self.add_parameter(self.param)
+ self.page_size = 2
+
def get(self, session):
return self.param.get(session)
def set(self, session, value):
return self.param.set(session, value)
+ def get_bounds(self, session):
+ page = self.get(session)
+ return (self.page_size * page, self.page_size * (page + 1))
+
def get_items(self, session, object):
- return range(0, int(ceil(len(object) / float(2))))
+ return range(0, int(ceil(len(object) / float(self.page_size))))
+
+ def render_item_class_attr(self, session, page):
+ if self.get(session) == page:
+ return " class=\"selected\""
def render_item_href(self, session, page):
branch = session.branch()
Modified: mgmt/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/cumin/python/cumin/widgets.strings 2007-11-27 16:26:44 UTC (rev 1370)
+++ mgmt/cumin/python/cumin/widgets.strings 2007-11-27 16:44:33 UTC (rev 1371)
@@ -26,10 +26,23 @@
<li>{bytes_link}</li>
</ul>
+[Paginator.css]
+div.Paginator {
+ margin: 0 0 0.5em 0;
+}
+
+div.Paginator ul {
+ display: inline;
+}
+
+div.Paginator li {
+ display: inline;
+}
+
[Paginator.html]
-<ul class="comma">
- {items}
-</ul>
+<div class="Paginator">
+ Page <ul class="comma">{items}</ul>
+</div>
[Paginator.item_html]
-<li><a href="{item_href}">{item_content}</a></li>
+<li><a {item_class_attr}
href="{item_href}">{item_content}</a></li>
Show replies by date