summaryrefslogtreecommitdiffstats
path: root/israwhidebroken/controllers.py
diff options
context:
space:
mode:
authorWill Woods <wwoods@redhat.com>2009-09-15 17:15:33 -0400
committerWill Woods <wwoods@redhat.com>2009-09-15 17:15:33 -0400
commit2823bdfb2ae660bd198a02ee621fb65f6bc792e3 (patch)
tree915e040cd4054adf317e46ea4a14b9923e3e63c0 /israwhidebroken/controllers.py
parent747bc663591b7883a3641b2b13c8b780f37be318 (diff)
downloadisrawhidebroken-2823bdfb2ae660bd198a02ee621fb65f6bc792e3.tar.gz
israwhidebroken-2823bdfb2ae660bd198a02ee621fb65f6bc792e3.tar.xz
israwhidebroken-2823bdfb2ae660bd198a02ee621fb65f6bc792e3.zip
Add add_tree method, pass more stuff to index, show real tree results and stuff
Diffstat (limited to 'israwhidebroken/controllers.py')
-rw-r--r--israwhidebroken/controllers.py59
1 files changed, 30 insertions, 29 deletions
diff --git a/israwhidebroken/controllers.py b/israwhidebroken/controllers.py
index 14e0fb6..4b3062d 100644
--- a/israwhidebroken/controllers.py
+++ b/israwhidebroken/controllers.py
@@ -15,12 +15,15 @@ def to_int(fstr):
class Root(controllers.RootController):
# Main index page
@expose(template="israwhidebroken.templates.index")
- def index(self):
- # TODO: find most recent tree(s)
+ def index(self, c=0):
+ if not c:
+ newest_tree = Tree.select(orderBy='-compose_id')[0]
+ c = newest_tree.compose_id
return dict(in_qa='qa' in identity.current.groups,
admin='qa-admin' in identity.current.groups,
+ c=c,
tests=Test.select(),
- treeid=0) # fake treeid
+ trees=Tree.select(Tree.q.compose_id == c))
# JSON RPC calls
@expose("json")
@@ -29,38 +32,36 @@ class Root(controllers.RootController):
return dict(tests=list(tests))
@expose("json")
- def get_trees(self, arch=None, tree_time=None, repodata_time=None):
- trees = []
- tree = None
- if tree_time:
- trees = list(Tree.select(
- AND(Tree.q.tree_time == to_int(tree_time),
- Tree.q.arch == arch),
- orderBy='tree_time'))
- elif repodata_time:
- trees = list(Tree.select(
- AND(Tree.q.repodata_time == to_int(repodata_time),
- Tree.q.arch == arch),
- orderBy='repodata_time'))
- return dict(trees=trees)
+ def get_trees(self, *args, **kw):
+ qlist = []
+ for field in 'arch', 'compose_id', 'tree_time', 'repodata_time':
+ if field in kw:
+ qlist.append('%s == %s' % (field, Tree.sqlrepr(kw[field])))
+ tree_results = Tree.select(' AND '.join(qlist))
+ return dict(trees=list(tree_results))
+
+ @expose("json")
+ @identity.require(identity.in_group("qa-admin"))
+ def add_tree(self, arch, compose_id, tree_time=None, repodata_time=None):
+ t = Tree(arch=arch,
+ compose_id=compose_id,
+ tree_time=tree_time,
+ repodata_time=repodata_time)
+ hub.commit()
+ return dict(tree=t)
@expose("json")
@identity.require(identity.in_group("qa"))
- def add_testresult(self, arch=None, tree_time=None, repodata_time=None, testid=0, result=0):
- # First, check to see if we have an existing Tree that matches
- r = self.get_trees(arch, tree_time, repodata_time)
- trees = r['trees']
- if len(trees):
- tree = trees[-1] # Pick the newest tree
- else:
- tree = Tree(arch = arch,
- tree_time = to_int(tree_time),
- repodata_time = to_int(repodata_time))
- hub.commit()
- tr = TestResult(test=testid, tree=tree.id, result=result)
+ def add_result(self, treeid, testid, result):
+ tr = TestResult(tree=treeid, test=testid, result=result)
hub.commit() # XXX redundant?
return dict(id=tr.id)
+ @expose("json")
+ @identity.require(identity.in_group("qa-admin"))
+ def delete_result(self, id):
+ return dict(youwantedtodelete=id, thisisastub=True)
+
# Identity stuff (login/logout)
@expose(template="israwhidebroken.templates.login")
def login(self, forward_url=None, *args, **kw):