diff options
| author | Will Woods <wwoods@redhat.com> | 2009-09-15 17:15:33 -0400 |
|---|---|---|
| committer | Will Woods <wwoods@redhat.com> | 2009-09-15 17:15:33 -0400 |
| commit | 2823bdfb2ae660bd198a02ee621fb65f6bc792e3 (patch) | |
| tree | 915e040cd4054adf317e46ea4a14b9923e3e63c0 | |
| parent | 747bc663591b7883a3641b2b13c8b780f37be318 (diff) | |
| download | israwhidebroken-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
| -rw-r--r-- | israwhidebroken/controllers.py | 59 | ||||
| -rw-r--r-- | israwhidebroken/templates/index.html | 41 |
2 files changed, 67 insertions, 33 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): diff --git a/israwhidebroken/templates/index.html b/israwhidebroken/templates/index.html index ca9bca8..b51ad04 100644 --- a/israwhidebroken/templates/index.html +++ b/israwhidebroken/templates/index.html @@ -11,13 +11,46 @@ <title>Is Rawhide Broken?</title> </head> +<?python +def rclass(r): + if r is None: return None + return r.result and 'pass' or 'fail' + +results = {} +for tree in trees: + rdict = dict([(t.id, None) for t in tests]) + for r in tree.results: + rdict[r.testID] = r + results[tree.id] = rdict +?> + <body> <table id="results"> - <tr py:for="test in tests" py:with="result='noresult'"> <!--! pass, fail --> - <td class="${result}"><a href="${test.uri}">${test.name}</a></td> - <td class="${result}">${result}<a py:if="in_qa" href="#in_qa">change result</a></td> + <th>Rawhide compose ${c}</th> + <th py:for="tree in trees">${tree.arch}</th> + <tr py:for="test in tests"> + <td><a href="${test.uri}">${test.name}</a></td> + <td py:for="tree in trees" py:with="r=results[tree.id][test.id]" + class="${rclass(r)}"> + <py:choose> + <!--! TODO FIXME form target --> + <!--! TODO FIXME FOR REAL nice widget to do this ajaxfully --> + <form py:when="in_qa and r is None and test.id == 8 or test.id == 9"> + <select name="result"> + <option>none</option> + <option value="1">pass</option> + <option value="0">fail</option> + </select> + <input type="hidden" name="testid" value="${test.id}"/> + <input type="hidden" name="treeid" value="${tree.id}"/> + </form> + <span py:otherwise="">${rclass(r) or 'none'}</span> + </py:choose> + <span py:if="admin and r is not None"> + <a href="${tg.url('/delete_result?id='+str(r.id))}">x</a> + </span> + </td> </tr> </table> - <div py:if="admin"><a href="#admin">delete this tree</a></div> </body> </html> |
