Fix URL validator to restore resubmission functionality.

This commit is contained in:
Andre D
2011-09-29 18:09:36 -04:00
committed by Max Goodman
parent d56089ee6e
commit 978e28f565
6 changed files with 11 additions and 8 deletions

View File

@@ -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'),

View File

@@ -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):

View File

@@ -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:

View File

@@ -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:

View File

@@ -107,7 +107,7 @@ ${thing.formtabs_menu}
${thing.captcha}
</div>
<input name="resubmit" value="${thing.resubmit}" type="hidden"/>
<div class="spacer">
Try our&#32;<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&#32;<a href="/iphonebookmarklet.compact?__javascript:location.href='http
select_form_tab(default_menu, "${thing.default_show}", "${thing.default_hide}");
}
</script>
%endif
%endif

View File

@@ -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>