summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Woods <wwoods@redhat.com>2009-10-01 12:51:38 -0400
committerWill Woods <wwoods@redhat.com>2009-10-01 12:51:38 -0400
commit01c618700447703eb2d8fb97228a7cccab9c07a2 (patch)
treee34ebfb1df5f58ea9c51544c724a85b5d092d032
parentc4d784328351a5a21fc679a45599e335da2faf1e (diff)
downloadisrawhidebroken-01c618700447703eb2d8fb97228a7cccab9c07a2.tar.gz
israwhidebroken-01c618700447703eb2d8fb97228a7cccab9c07a2.tar.xz
israwhidebroken-01c618700447703eb2d8fb97228a7cccab9c07a2.zip
Change args to index and add_result so we can pass csrf token along
-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)