From 9605865b5dafc58f1be71be31268df7db58f66e1 Mon Sep 17 00:00:00 2001 From: DEADB33F Date: Thu, 12 Apr 2012 16:55:45 +0100 Subject: [PATCH] Added ability to specify self text via the submit url paramaters. eg /submit?text=Example%20sefltext --- r2/r2/controllers/front.py | 4 +++- r2/r2/lib/pages/pages.py | 13 +++++++++---- r2/r2/templates/newlink.html | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) mode change 100644 => 100755 r2/r2/controllers/front.py mode change 100644 => 100755 r2/r2/lib/pages/pages.py mode change 100644 => 100755 r2/r2/templates/newlink.html diff --git a/r2/r2/controllers/front.py b/r2/r2/controllers/front.py old mode 100644 new mode 100755 index 64dc17ffb..34550a2d7 --- a/r2/r2/controllers/front.py +++ b/r2/r2/controllers/front.py @@ -780,8 +780,9 @@ class FrontController(RedditController): @validate(url = VRequired('url', None), title = VRequired('title', None), + text = VRequired('text', None), then = VOneOf('then', ('tb','comments'), default = 'comments')) - def GET_submit(self, url, title, then): + def GET_submit(self, url, title, text, then): """Submit form.""" resubmit = request.get.get('resubmit') if url and not resubmit: @@ -812,6 +813,7 @@ class FrontController(RedditController): page_classes=['submit-page'], content=NewLink(url=url or '', title=title or '', + text=text or '', subreddits = sr_names, captcha=captcha, resubmit=resubmit, diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py old mode 100644 new mode 100755 index d4db03b13..a013e20a8 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -1817,8 +1817,8 @@ class FrameToolbar(Wrapped): class NewLink(Templated): """Render the link submission form""" - def __init__(self, captcha = None, url = '', title= '', subreddits = (), - then = 'comments', resubmit=False): + def __init__(self, captcha = None, url = '', title= '', text = '', + subreddits = (), then = 'comments', resubmit=False): self.show_link = self.show_self = False @@ -1833,7 +1833,12 @@ class NewLink(Templated): if self.show_self and self.show_link: all_fields = set(chain(*(parts for (tab, parts) in tabs))) buttons = [] - self.default_tab = tabs[0][0] + + if text != '': + self.default_tab = tabs[1][0] + else: + self.default_tab = tabs[0][0] + for tab_name, parts in tabs: to_show = ','.join('#' + p for p in parts) to_hide = ','.join('#' + p for p in all_fields if p not in parts) @@ -1856,7 +1861,7 @@ class NewLink(Templated): self.default_sr = c.site Templated.__init__(self, captcha = captcha, url = url, - title = title, subreddits = subreddits, + title = title, text = text, subreddits = subreddits, then = then) class ShareLink(CachedTemplate): diff --git a/r2/r2/templates/newlink.html b/r2/r2/templates/newlink.html old mode 100644 new mode 100755 index 08def0abf..06023f377 --- a/r2/r2/templates/newlink.html +++ b/r2/r2/templates/newlink.html @@ -89,7 +89,7 @@ ${thing.formtabs_menu} <%utils:round_field title="${_('text')}", description="${_('(optional)')}" id="text-field"> - ${UserText(None, have_form = False, creating = True)} + ${UserText(None, text = thing.text, have_form = False, creating = True)} ${error_field("NO_SELFS", "sr")}