page.py: exit prompt added
logout prompt now works as intended
This commit is contained in:
@@ -106,7 +106,7 @@ class OAuthTool(object):
|
||||
except (praw.errors.OAuthAppRequired, praw.errors.OAuthInvalidToken):
|
||||
show_notification(self.stdscr, ['Invalid OAuth data'])
|
||||
else:
|
||||
message = ['Welcome {}!'.format(self.reddit.user.name)]
|
||||
message = ['Welcome, {}!'.format(self.reddit.user.name)]
|
||||
show_notification(self.stdscr, message)
|
||||
|
||||
def clear_oauth_data(self):
|
||||
|
||||
28
rtv/page.py
28
rtv/page.py
@@ -265,7 +265,15 @@ class BasePage(object):
|
||||
|
||||
@BaseController.register('q')
|
||||
def exit(self):
|
||||
"""
|
||||
Prompt to exit the application.
|
||||
"""
|
||||
|
||||
ch = prompt_input(self.stdscr, "Do you really want to quit? (y/n): ")
|
||||
if ch == 'y':
|
||||
sys.exit()
|
||||
elif ch != 'n':
|
||||
curses.flash()
|
||||
|
||||
@BaseController.register('?')
|
||||
def help(self):
|
||||
@@ -350,8 +358,12 @@ class BasePage(object):
|
||||
"""
|
||||
|
||||
if self.reddit.is_oauth_session():
|
||||
self.oauth.clear_oauth_data()
|
||||
ch = prompt_input(self.stdscr, "Log out? (y/n): ")
|
||||
if ch == 'y':
|
||||
self.reddit.clear_authentication()
|
||||
show_notification(self.stdscr, ['Logged out'])
|
||||
elif ch != 'n':
|
||||
curses.flash()
|
||||
else:
|
||||
self.oauth.authorize()
|
||||
|
||||
@@ -370,7 +382,7 @@ class BasePage(object):
|
||||
curses.flash()
|
||||
return
|
||||
|
||||
prompt = 'Are you sure you want to delete this? (y/n):'
|
||||
prompt = 'Are you sure you want to delete this? (y/n): '
|
||||
char = prompt_input(self.stdscr, prompt)
|
||||
if char != 'y':
|
||||
show_notification(self.stdscr, ['Aborted'])
|
||||
@@ -446,18 +458,6 @@ class BasePage(object):
|
||||
continue
|
||||
self.stdscr.nodelay(0)
|
||||
|
||||
def logout(self):
|
||||
"""
|
||||
Prompt to log out of the user's account.
|
||||
"""
|
||||
|
||||
ch = prompt_input(self.stdscr, "Log out? (y/n):")
|
||||
if ch == 'y':
|
||||
self.reddit.clear_authentication()
|
||||
show_notification(self.stdscr, ['Logged out'])
|
||||
elif ch != 'n':
|
||||
curses.flash()
|
||||
|
||||
@property
|
||||
def safe_call(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user