From 23f97cda9cc29f66e5a36162dad4a624ed33a638 Mon Sep 17 00:00:00 2001 From: Will Woods Date: Thu, 24 Sep 2009 17:00:40 -0400 Subject: Add links to prev/next compose --- israwhidebroken/controllers.py | 15 +++++++++++---- israwhidebroken/templates/index.html | 4 +++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/israwhidebroken/controllers.py b/israwhidebroken/controllers.py index ecd11a2..9727b47 100644 --- a/israwhidebroken/controllers.py +++ b/israwhidebroken/controllers.py @@ -16,12 +16,19 @@ class Root(controllers.RootController): # Main index page @expose(template="israwhidebroken.templates.index") def index(self, c=None): + c = to_int(c) + # FIXME This is really, really stupid - use a LIMIT or something + composelist = sorted(set([t.compose_id for t in Tree.select()])) if not c: - newest_tree = Tree.select(orderBy='-compose_id')[0] - c = newest_tree.compose_id + c = composelist[-1] + prev = composelist[-2] + next = None + elif c in composelist: + idx = composelist.index(c) + prev = (idx > 0) and composelist[idx-1] or None + next = (idx+1 < len(composelist)) and composelist[idx+1] or None # FIXME BLUH WIDGETIFY THIS - # TODO need id of prev/next compose for navigation/browsing - return dict(c=c, + return dict(c=c, prev=prev, next=next, in_qa='qa' in identity.current.groups, admin='qa-admin' in identity.current.groups, tests=Test.select(), diff --git a/israwhidebroken/templates/index.html b/israwhidebroken/templates/index.html index bf8474e..24b2451 100644 --- a/israwhidebroken/templates/index.html +++ b/israwhidebroken/templates/index.html @@ -26,7 +26,9 @@ for tree in trees: - + -- cgit
Rawhide compose ${c}« + Rawhide compose ${c} + » ${tree.arch}
${test.name}