summaryrefslogtreecommitdiffstats
path: root/israwhidebroken/controllers.py
diff options
context:
space:
mode:
Diffstat (limited to 'israwhidebroken/controllers.py')
-rw-r--r--israwhidebroken/controllers.py27
1 files changed, 12 insertions, 15 deletions
diff --git a/israwhidebroken/controllers.py b/israwhidebroken/controllers.py
index de12683..c2ad902 100644
--- a/israwhidebroken/controllers.py
+++ b/israwhidebroken/controllers.py
@@ -11,19 +11,15 @@ import tw.forms as twf
# Simple select widget for submitting test results
# TODO: ajaxify
-result_form = twf.Form('resultform',
- action = 'add_result',
- #submit_text = None,
- children = [
- twf.SingleSelectField('result', options=['none','pass','fail'],
- suppress_label=True),
- twf.HiddenField('testid'),
- twf.HiddenField('treeid'),
- twf.HiddenField('c'), # This is kinda stupid
- # XXX fixme need to pass _csrf_token too?
- # Feel like I'm doing this wrong somehow..
+class ResultForm(twf.Form):
+ show_errors = True
+ fields = [
+ twf.SingleSelectField('result', options=['none','pass','fail'],
+ suppress_label=True),
+ twf.HiddenField('testid'),
+ twf.HiddenField('treeid'),
]
-)
+
fdict = {'none': None, 'pass': 1, 'fail': 0}
def to_int(fstr):
@@ -35,7 +31,7 @@ def to_int(fstr):
class Root(controllers.RootController):
# Main index page
@expose(template="israwhidebroken.templates.index")
- def index(self, c=None):
+ def index(self, c=None, *args, **kw):
if not c:
c = Tree.select().max('compose_id')
next = None
@@ -53,6 +49,7 @@ class Root(controllers.RootController):
rdict[r.testID] = r
results[tree.id] = rdict
+ result_form = ResultForm('resultform', action=tg.url('/add_result', kw))
return dict(c=c, prev=prev, next=next,
result_form=result_form,
in_qa='qa' in identity.current.groups,
@@ -111,7 +108,7 @@ class Root(controllers.RootController):
@identity.require(identity.in_group("qa"))
@expose(allow_json=True)
- def add_result(self, treeid, testid, result, overwrite=False, c=None):
+ def add_result(self, treeid, testid, result, overwrite=False, *args, **kw):
if not overwrite:
# TODO return an exception if there's already a result here
pass
@@ -123,7 +120,7 @@ class Root(controllers.RootController):
hub.commit() # XXX necessary?
if 'json' in fedora.tg.util.request_format():
return dict(id=tr.id)
- redirect("/", c=c)
+ redirect(tg.url("/", kw))
@identity.require(identity.in_group("qa"))
@expose(allow_json=True)