From 6f2dd9f528b8e5b570506659982baeb52e515692 Mon Sep 17 00:00:00 2001 From: Tobin Date: Mon, 6 Apr 2015 11:39:57 -0500 Subject: [PATCH] edited style to match other functions --- rtv/page.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/rtv/page.py b/rtv/page.py index 3b846da..fa9a412 100644 --- a/rtv/page.py +++ b/rtv/page.py @@ -257,22 +257,24 @@ class BasePage(object): Delete a submission or comment. """ data = self.content.get(self.nav.absolute_index) - if data['author'] == self.reddit.user.name: - prompt = 'Are you sure you want to delete this? (y/n):' - char = self.prompt_input(prompt) - if char == 'y': - try: - data['object'].delete() - show_notification(self.stdscr, ['Deleted']) - except praw.errors.APIException as e: - show_notification(self.stdscr, [e.message]) - else: - time.sleep(0.5) - self.refresh_content() - else: - show_notification(self.stdscr, ['Delete cancelled']) - else: + if data['author'] != self.reddit.user.name: show_notification(self.stdscr, ['You can\'t delete this']) + return + + prompt = 'Are you sure you want to delete this? (y/n):' + char = self.prompt_input(prompt) + if char != 'y': + show_notification(self.stdscr, ['Delete cancelled']) + return + + try: + data['object'].delete() + show_notification(self.stdscr, ['Deleted']) + except praw.errors.APIException as e: + show_notification(self.stdscr, [e.message]) + else: + time.sleep(0.5) + self.refresh_content() def logout(self): "Prompt to log out of the user's account."