catch key error, omit extra notifications
This commit is contained in:
16
rtv/page.py
16
rtv/page.py
@@ -257,9 +257,15 @@ class BasePage(object):
|
|||||||
"""
|
"""
|
||||||
Delete a submission or comment.
|
Delete a submission or comment.
|
||||||
"""
|
"""
|
||||||
|
if not self.reddit.is_logged_in():
|
||||||
|
show_notification(self.stdscr, ['Login to delete'])
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
data = self.content.get(self.nav.absolute_index)
|
data = self.content.get(self.nav.absolute_index)
|
||||||
if data['author'] != self.reddit.user.name:
|
if data['author'] != self.reddit.user.name:
|
||||||
show_notification(self.stdscr, ['You can\'t delete this'])
|
return
|
||||||
|
except KeyError:
|
||||||
return
|
return
|
||||||
|
|
||||||
prompt = 'Are you sure you want to delete this? (y/n):'
|
prompt = 'Are you sure you want to delete this? (y/n):'
|
||||||
@@ -282,9 +288,15 @@ class BasePage(object):
|
|||||||
"""
|
"""
|
||||||
Edit a submission or comment.
|
Edit a submission or comment.
|
||||||
"""
|
"""
|
||||||
|
if not self.reddit.is_logged_in():
|
||||||
|
show_notification(self.stdscr, ['Login to edit'])
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
data = self.content.get(self.nav.absolute_index)
|
data = self.content.get(self.nav.absolute_index)
|
||||||
if data['author'] != self.reddit.user.name:
|
if data['author'] != self.reddit.user.name:
|
||||||
show_notification(self.stdscr, ['You can\'t edit this'])
|
return
|
||||||
|
except KeyError:
|
||||||
return
|
return
|
||||||
|
|
||||||
if data['type'] == 'Submission':
|
if data['type'] == 'Submission':
|
||||||
|
|||||||
Reference in New Issue
Block a user