mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-31 09:48:01 -05:00
Fix URL validator to restore resubmission functionality.
This commit is contained in:
@@ -175,7 +175,7 @@ class ApiController(RedditController):
|
||||
prefix = "rate_submit_"),
|
||||
ip = ValidIP(),
|
||||
sr = VSubmitSR('sr', 'kind'),
|
||||
url = VUrl(['url', 'sr']),
|
||||
url = VUrl(['url', 'sr', 'resubmit']),
|
||||
title = VTitle('title'),
|
||||
save = VBoolean('save'),
|
||||
selftext = VSelfText('text'),
|
||||
|
||||
@@ -677,7 +677,8 @@ class FrontController(RedditController):
|
||||
then = VOneOf('then', ('tb','comments'), default = 'comments'))
|
||||
def GET_submit(self, url, title, then):
|
||||
"""Submit form."""
|
||||
if url and not request.get.get('resubmit'):
|
||||
resubmit = request.get.get('resubmit')
|
||||
if url and not resubmit:
|
||||
# check to see if the url has already been submitted
|
||||
links = link_from_url(url)
|
||||
if links and len(links) == 1:
|
||||
@@ -706,6 +707,7 @@ class FrontController(RedditController):
|
||||
title=title or '',
|
||||
subreddits = sr_names,
|
||||
captcha=captcha,
|
||||
resubmit=resubmit,
|
||||
then = then)).render()
|
||||
|
||||
def GET_frame(self):
|
||||
|
||||
@@ -891,7 +891,7 @@ class VUrl(VRequired):
|
||||
self.lookup = lookup
|
||||
VRequired.__init__(self, item, errors.NO_URL, *a, **kw)
|
||||
|
||||
def run(self, url, sr = None):
|
||||
def run(self, url, sr = None, resubmit=False):
|
||||
if sr is None and not isinstance(c.site, FakeSubreddit):
|
||||
sr = c.site
|
||||
elif sr:
|
||||
@@ -912,7 +912,7 @@ class VUrl(VRequired):
|
||||
if url == 'self':
|
||||
if self.allow_self:
|
||||
return url
|
||||
elif not self.lookup:
|
||||
elif not self.lookup or resubmit:
|
||||
return url
|
||||
elif url:
|
||||
try:
|
||||
|
||||
@@ -1753,7 +1753,7 @@ class FrameToolbar(Wrapped):
|
||||
class NewLink(Templated):
|
||||
"""Render the link submission form"""
|
||||
def __init__(self, captcha = None, url = '', title= '', subreddits = (),
|
||||
then = 'comments'):
|
||||
then = 'comments', resubmit=False):
|
||||
|
||||
self.show_link = self.show_self = False
|
||||
|
||||
@@ -1784,6 +1784,7 @@ class NewLink(Templated):
|
||||
|
||||
self.sr_searches = simplejson.dumps(popular_searches())
|
||||
|
||||
self.resubmit = resubmit
|
||||
if c.default_sr:
|
||||
self.default_sr = None
|
||||
else:
|
||||
|
||||
@@ -107,7 +107,7 @@ ${thing.formtabs_menu}
|
||||
${thing.captcha}
|
||||
|
||||
</div>
|
||||
|
||||
<input name="resubmit" value="${thing.resubmit}" type="hidden"/>
|
||||
<div class="spacer">
|
||||
Try our <a href="/iphonebookmarklet.compact?__javascript:location.href='http://${g.domain}/submit.compact?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)">bookmarklet</a>.
|
||||
<button class="btn save button" name="submit" value="form" type="submit">${_("submit")}</button>
|
||||
@@ -125,4 +125,4 @@ Try our <a href="/iphonebookmarklet.compact?__javascript:location.href='http
|
||||
select_form_tab(default_menu, "${thing.default_show}", "${thing.default_hide}");
|
||||
}
|
||||
</script>
|
||||
%endif
|
||||
%endif
|
||||
|
||||
@@ -105,7 +105,7 @@ ${thing.formtabs_menu}
|
||||
${thing.captcha}
|
||||
|
||||
</div>
|
||||
|
||||
<input name="resubmit" value="${thing.resubmit}" type="hidden"/>
|
||||
<div class="spacer">
|
||||
<button class="btn" name="submit" value="form" type="submit">${_("submit")}</button>
|
||||
<span class="status"></span>
|
||||
|
||||
Reference in New Issue
Block a user