Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix duplicate url submission workflow #721

Closed
wants to merge 1 commit into from

4 participants

@milkypostman

Previously when a duplicate url fragment was submitted, the user was
redirected to the comments page where they were provided a link to
resubmit the link. This resulting link did not include the original
url. This patch adds changes that preserve the url and title
throughout the submission workflow.

@milkypostman

cleaned up the commit to not include whitespace fixes. those are coming in another commit.

r2/r2/models/link.py
@@ -120,13 +120,15 @@ def set_url_cache(self):
LinksByUrl._set_values(LinksByUrl._key_from_url(self.url),
{self._id36: ''})
- @property
- def already_submitted_link(self):
- return self.make_permalink_slow() + '?already_submitted=true'
+ def already_submitted_link(self, url, title):

If title is optional (line 126 makes it seem that way), it should be a keyword argument.

Edit: Same for URL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kemitche

Beyond the one minor nit I mentioned, this one gets my :fish: (pending internal testing)

@kemitche

This will fix #225

@milkypostman

haven't had a chance to update this. are you waiting on me to make the final changes?

@kemitche

I won't be able to pull this through to completion; if you could update to fix the previously mentioned nit, I believe someone will pull it in when they have time.

@milkypostman milkypostman fixes bug in duplicate url workflow
Previously when a duplicate url fragment was submitted, the user was
redirected to the comments page where they were provided a link to
resubmit the link. This resulting link did not include the original
url. This patch adds changes that preserve the url and title
throughout the submission workflow.

Fixes:
http://www.reddit.com/r/bugs/comments/1af12e/resubmitting_links_with_url_fragments_copies_a/
9bbd33f
@milkypostman

@kemitche sorry it took so long for me to fix this up. I just force pushed a new version of the commit that adds the optional arguments.

@akkatracker

Any updates on this?

@milkypostman
@kjoconnor kjoconnor closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 26, 2013
  1. @milkypostman

    fixes bug in duplicate url workflow

    milkypostman authored
    Previously when a duplicate url fragment was submitted, the user was
    redirected to the comments page where they were provided a link to
    resubmit the link. This resulting link did not include the original
    url. This patch adds changes that preserve the url and title
    throughout the submission workflow.
    
    Fixes:
    http://www.reddit.com/r/bugs/comments/1af12e/resubmitting_links_with_url_fragments_copies_a/
This page is out of date. Refresh to see the latest.
View
4 r2/r2/controllers/api.py
@@ -321,7 +321,9 @@ def POST_submit(self, form, jquery, url, selftext, kind, title,
g.stats.simple_event('spam.shame.link')
elif form.has_errors("url", errors.ALREADY_SUB):
check_domain = False
- u = url[0].already_submitted_link
+ u = utils.tup(Link._by_url(url, sr))[0]
+ u = u.already_submitted_link(url=url, title=title)
+
if extension:
u = UrlParser(u)
u.set_extension(extension)
View
14 r2/r2/controllers/front.py
@@ -252,7 +252,10 @@ def GET_comments(self, article, comment, context, sort, limit, depth):
# check if we just came from the submit page
infotext = None
if request.get.get('already_submitted'):
- infotext = strings.already_submitted % article.resubmit_link()
+ infotext = strings.already_submitted % article.resubmit_link(
+ sr_url=True,
+ url=request.get.get('already_submitted'),
+ title=request.get.get('title'))
check_cheating('comments')
@@ -920,11 +923,16 @@ def GET_submit(self, url, title, text, selftext, then):
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:
- return self.redirect(links[0].already_submitted_link)
+ u = links[0].already_submitted_link(url=url, title=title)
+ return self.redirect(u)
elif links:
infotext = (strings.multiple_submitted
- % links[0].resubmit_link())
+ % links[0].resubmit_link(
+ sr_url=True,
+ url=request.get.get('already_submitted'),
+ title=request.get.get('title')))
res = BoringPage(_("seen it"),
content=wrap_links(links),
infotext=infotext).render()
View
2  r2/r2/lib/validator/validator.py
@@ -1182,7 +1182,7 @@ def run(self, url, sr = None, resubmit=False):
try:
l = Link._by_url(url, sr)
self.error(errors.ALREADY_SUB)
- return utils.tup(l)
+ return url
except NotFound:
return url
return self.error(errors.BAD_URL)
View
12 r2/r2/models/link.py
@@ -120,13 +120,15 @@ def set_url_cache(self):
LinksByUrl._set_values(LinksByUrl._key_from_url(self.url),
{self._id36: ''})
- @property
- def already_submitted_link(self):
- return self.make_permalink_slow() + '?already_submitted=true'
+ def already_submitted_link(self, url=None, title=None):
+ return self.make_permalink_slow() + \
+ '?already_submitted=' + url_escape(url or self.url) + \
+ '&title=' + url_escape(title or self.title)
- def resubmit_link(self, sr_url=False):
+ def resubmit_link(self, sr_url=False, url=False, title=False):
submit_url = self.subreddit_slow.path if sr_url else '/'
- submit_url += 'submit?resubmit=true&url=' + url_escape(self.url)
+ submit_url += 'submit?resubmit=true&url=' + url_escape(url or self.url)
+ submit_url += '&title=' + url_escape(title or self.title)
return submit_url
@classmethod
Something went wrong with that request. Please try again.