Add sendreplies attribute to Link.

This commit is contained in:
Jason Harvey
2013-02-26 08:03:12 -08:00
parent 56100fe108
commit 4bcf604f74
2 changed files with 8 additions and 3 deletions

View File

@@ -235,6 +235,7 @@ class ApiController(RedditController, OAuth2ResourceController):
url = VUrl(['url', 'sr', 'resubmit']),
title = VTitle('title'),
save = VBoolean('save'),
sendreplies = VBoolean('sendreplies'),
selftext = VSelfText('text'),
kind = VOneOf('kind', ['link', 'self']),
then = VOneOf('then', ('tb', 'comments'),
@@ -244,7 +245,7 @@ class ApiController(RedditController, OAuth2ResourceController):
)
@api_doc(api_section.links_and_comments)
def POST_submit(self, form, jquery, url, selftext, kind, title,
save, sr, ip, then, extension):
save, sr, ip, then, extension, sendreplies):
"""Submit a link to a subreddit.
Submit will create a link or self-post in the subreddit `sr` with the
@@ -373,9 +374,11 @@ class ApiController(RedditController, OAuth2ResourceController):
form.set_error(errors.QUOTA_FILLED, None)
return
sendreplies = kind == 'self'
# well, nothing left to do but submit it
l = Link._submit(request.post.title, url if kind == 'link' else 'self',
c.user, sr, ip, spam=c.user._spam)
c.user, sr, ip, spam=c.user._spam, sendreplies=sendreplies)
if banmsg:
g.stats.simple_event('spam.domainban.link_url')

View File

@@ -68,6 +68,7 @@ class Link(Thing, Printable):
disable_comments=False,
selftext='',
noselfreply=False,
sendreplies=True,
ip='0.0.0.0',
flair_text=None,
flair_css_class=None,
@@ -142,7 +143,7 @@ class Link(Thing, Printable):
return cls._defaults['comment_tree_version']
@classmethod
def _submit(cls, title, url, author, sr, ip, spam=False):
def _submit(cls, title, url, author, sr, ip, spam=False, sendreplies=True):
from r2.models import admintools
l = cls(_ups=1,
@@ -150,6 +151,7 @@ class Link(Thing, Printable):
url=url,
_spam=spam,
author_id=author._id,
sendreplies=sendreplies,
sr_id=sr._id,
lang=sr.lang,
ip=ip,