fix subreddit name when user tries to post to /new etc.

This commit is contained in:
Tobin
2015-04-01 16:27:42 -05:00
parent feffe83e06
commit 26d4d247b0
2 changed files with 6 additions and 5 deletions

View File

@@ -60,5 +60,5 @@ SUBMISSION_FILE = """
# The first line will be interpreted as the title # The first line will be interpreted as the title
# Following lines will be interpreted as the content # Following lines will be interpreted as the content
# #
# Posting to {name} # Posting to /r/{name}
""" """

View File

@@ -101,9 +101,10 @@ class SubredditPage(BasePage):
subreddit = self.reddit.get_subreddit(self.content.name) subreddit = self.reddit.get_subreddit(self.content.name)
# Make sure it is a valid subreddit for submission # Make sure it is a valid subreddit for submission
sub = str(subreddit) # Strips the subreddit to just the name
if '+' in sub or sub == '/r/all' or sub == '/r/front': sub = str(subreddit).split('/')[2]
message = 'Can\'t post to {0}'.format(sub) if '+' in sub or sub == 'all' or sub == 'front':
message = 'Can\'t post to /r/{0}'.format(sub)
show_notification(self.stdscr, [message]) show_notification(self.stdscr, [message])
return return
@@ -119,7 +120,7 @@ class SubredditPage(BasePage):
return return
try: try:
title, content = submission_text.split('\n', 1) title, content = submission_text.split('\n', 1)
self.reddit.submit(subreddit, title, text=content) self.reddit.submit(sub, title, text=content)
except praw.errors.APIException as e: except praw.errors.APIException as e:
show_notification(self.stdscr, [e.message]) show_notification(self.stdscr, [e.message])
else: else: