From 4bcf604f74bae092b3598b5590b00eace2a98325 Mon Sep 17 00:00:00 2001 From: Jason Harvey Date: Tue, 26 Feb 2013 08:03:12 -0800 Subject: [PATCH] Add sendreplies attribute to Link. --- r2/r2/controllers/api.py | 7 +++++-- r2/r2/models/link.py | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index ffb737382..cef169033 100755 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -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') diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index e8ef2742e..dd0fd9aff 100755 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -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,