Skip to content

Commit

Permalink
Preserve the originally attempted title when resubmitting a link.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pokechu22 authored and bsimpson63 committed Jul 30, 2015
1 parent 3ab3329 commit c942cef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion r2/r2/controllers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def POST_submit(self, form, jquery, url, selftext, kind, title,
if links:
c.errors.add(errors.ALREADY_SUB, field='url')
form.has_errors('url', errors.ALREADY_SUB)
u = links[0].already_submitted_link(url)
u = links[0].already_submitted_link(url, title)
if extension:
u = UrlParser(u)
u.set_extension(extension)
Expand Down
8 changes: 5 additions & 3 deletions r2/r2/controllers/front.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ def GET_comments(
infotext = None
if request.GET.get('already_submitted'):
submit_url = request.GET.get('submit_url') or article.url
resubmit_url = Link.resubmit_link(submit_url)
submit_title = request.GET.get('submit_title') or ""
resubmit_url = Link.resubmit_link(submit_url, submit_title)
if c.user_is_loggedin and c.site.can_submit(c.user):
resubmit_url = add_sr(resubmit_url)
infotext = strings.already_submitted % resubmit_url
Expand Down Expand Up @@ -1225,12 +1226,13 @@ def GET_submit(self, url, title, text, selftext):

if links and len(links) == 1:
# redirect the user to the existing link's comments
existing_submission_url = links[0].already_submitted_link(url)
existing_submission_url = links[0].already_submitted_link(
url, title)
return self.redirect(existing_submission_url)
elif links:
# show the user a listing of all the other links with this url
# an infotext to resubmit it
resubmit_url = Link.resubmit_link(url)
resubmit_url = Link.resubmit_link(url, title)
sr_resubmit_url = add_sr(resubmit_url)
infotext = strings.multiple_submitted % sr_resubmit_url
res = BoringPage(
Expand Down
9 changes: 5 additions & 4 deletions r2/r2/models/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,17 @@ def set_url_cache(self):
LinksByUrl._set_values(LinksByUrl._key_from_url(self.url),
{self._id36: ''})

def already_submitted_link(self, url):
def already_submitted_link(self, url, title):
permalink = self.make_permalink_slow()
p = UrlParser(permalink)
p.update_query(already_submitted="true", submit_url=url)
p.update_query(already_submitted="true", submit_url=url,
submit_title=title)
return p.unparse()

@classmethod
def resubmit_link(cls, url):
def resubmit_link(cls, url, title):
p = UrlParser("/submit")
p.update_query(resubmit="true", url=url)
p.update_query(resubmit="true", url=url, title=title)
return p.unparse()

@classmethod
Expand Down

0 comments on commit c942cef

Please sign in to comment.