diff options
author | Will Woods <wwoods@redhat.com> | 2009-09-16 17:39:09 -0400 |
---|---|---|
committer | Will Woods <wwoods@redhat.com> | 2009-09-16 17:39:09 -0400 |
commit | 7b88a0d4e8d72af06358f685c06e20ed705711d1 (patch) | |
tree | 53727c5fbb8e55b9703d0254f4a32ca8868c3ff2 /israwhidebroken | |
parent | 78d6dd2fea33326a60c1aca851bd23a0b529a6f1 (diff) | |
download | israwhidebroken-7b88a0d4e8d72af06358f685c06e20ed705711d1.tar.gz israwhidebroken-7b88a0d4e8d72af06358f685c06e20ed705711d1.tar.xz israwhidebroken-7b88a0d4e8d72af06358f685c06e20ed705711d1.zip |
try to fix up add_tree
Diffstat (limited to 'israwhidebroken')
-rw-r--r-- | israwhidebroken/controllers.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/israwhidebroken/controllers.py b/israwhidebroken/controllers.py index 6e1c90a..cbe317a 100644 --- a/israwhidebroken/controllers.py +++ b/israwhidebroken/controllers.py @@ -32,34 +32,44 @@ class Root(controllers.RootController): tests = Test.select() return dict(tests=list(tests)) - @expose(allow_json=True) - def get_trees(self, *args, **kw): + def _tree_select(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)) + return Tree.select(' AND '.join(qlist)) @expose(allow_json=True) + def get_trees(self, *args, **kw): + tree_results = self._tree_select(*args, **kw) + return dict(trees=list(tree_results)) + @identity.require(identity.in_group("qa-admin")) + @expose(allow_json=True) def add_tree(self, arch, compose_id, tree_time=None, repodata_time=None): + # check to see if tree already exists + tree_result = self._tree_select(arch=arch, compose_id=compose_id, + tree_time=tree_time, repodata_time=repodata_time) + if tree_result.count(): + return dict(exc='ValueError', tg_flash='Tree exists') t = Tree(arch=arch, - compose_id=compose_id, - tree_time=tree_time, - repodata_time=repodata_time) + compose_id=to_int(compose_id), + tree_time=to_int(tree_time), + repodata_time=to_int(repodata_time)) hub.commit() return dict(tree=t) - @expose(allow_json=True) @identity.require(identity.in_group("qa")) + @expose(allow_json=True) def add_result(self, treeid, testid, result): - tr = TestResult(tree=treeid, test=testid, result=result) + tr = TestResult(tree=to_int(treeid), + test=to_int(testid), + result=to_int(result)) hub.commit() # XXX redundant? return dict(id=tr.id) - @expose(allow_json=True) @identity.require(identity.in_group("qa-admin")) + @expose(allow_json=True) def delete_result(self, id): return dict(youwantedtodelete=id, thisisastub=True) |