added deleting comment or submission
This commit is contained in:
23
rtv/page.py
23
rtv/page.py
@@ -251,6 +251,29 @@ class BasePage(object):
|
|||||||
else:
|
else:
|
||||||
show_notification(self.stdscr, ['Welcome {}'.format(username)])
|
show_notification(self.stdscr, ['Welcome {}'.format(username)])
|
||||||
|
|
||||||
|
@BaseController.register('d')
|
||||||
|
def delete(self):
|
||||||
|
"""
|
||||||
|
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:
|
||||||
|
show_notification(self.stdscr, ['You can\'t delete this'])
|
||||||
|
|
||||||
def logout(self):
|
def logout(self):
|
||||||
"Prompt to log out of the user's account."
|
"Prompt to log out of the user's account."
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user