From a9aa4ac5788075ba1b07cb86bc8343fa414ed3c5 Mon Sep 17 00:00:00 2001 From: DEADB33F Date: Thu, 12 Apr 2012 21:44:04 +0100 Subject: [PATCH] Added boolean paramater 'selftext' to /submit urls, if true submit page will default to displaying the 'text' tab. --- r2/r2/controllers/front.py | 4 +++- r2/r2/lib/pages/pages.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/r2/r2/controllers/front.py b/r2/r2/controllers/front.py index 34550a2d7..f30a2c222 100755 --- a/r2/r2/controllers/front.py +++ b/r2/r2/controllers/front.py @@ -781,8 +781,9 @@ class FrontController(RedditController): @validate(url = VRequired('url', None), title = VRequired('title', None), text = VRequired('text', None), + selftext = VRequired('selftext', None), then = VOneOf('then', ('tb','comments'), default = 'comments')) - def GET_submit(self, url, title, text, then): + def GET_submit(self, url, title, text, selftext, then): """Submit form.""" resubmit = request.get.get('resubmit') if url and not resubmit: @@ -814,6 +815,7 @@ class FrontController(RedditController): content=NewLink(url=url or '', title=title or '', text=text or '', + selftext=selftext or '', subreddits = sr_names, captcha=captcha, resubmit=resubmit, diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index a013e20a8..152c083e3 100755 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -1817,7 +1817,7 @@ class FrameToolbar(Wrapped): class NewLink(Templated): """Render the link submission form""" - def __init__(self, captcha = None, url = '', title= '', text = '', + def __init__(self, captcha = None, url = '', title= '', text = '', selftext = '', subreddits = (), then = 'comments', resubmit=False): self.show_link = self.show_self = False @@ -1834,7 +1834,7 @@ class NewLink(Templated): all_fields = set(chain(*(parts for (tab, parts) in tabs))) buttons = [] - if text != '': + if selftext == 'true' or text != '': self.default_tab = tabs[1][0] else: self.default_tab = tabs[0][0]