Add blocking=True to shared.feature_permission
This commit is contained in:
parent
be95d6f505
commit
05e73872b6
@ -196,7 +196,8 @@ def ignore_certificate_errors(url, errors, abort_on):
|
|||||||
raise utils.Unreachable
|
raise utils.Unreachable
|
||||||
|
|
||||||
|
|
||||||
def feature_permission(url, option, msg, yes_action, no_action, abort_on):
|
def feature_permission(url, option, msg, yes_action, no_action, abort_on,
|
||||||
|
blocking=False):
|
||||||
"""Handle a feature permission request.
|
"""Handle a feature permission request.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -206,9 +207,11 @@ def feature_permission(url, option, msg, yes_action, no_action, abort_on):
|
|||||||
yes_action: A callable to call if the request was approved
|
yes_action: A callable to call if the request was approved
|
||||||
no_action: A callable to call if the request was denied
|
no_action: A callable to call if the request was denied
|
||||||
abort_on: A list of signals which interrupt the question.
|
abort_on: A list of signals which interrupt the question.
|
||||||
|
blocking: If True, ask a blocking question.
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
The Question object if a question was asked, None otherwise.
|
The Question object if a question was asked (and blocking=False),
|
||||||
|
None otherwise.
|
||||||
"""
|
"""
|
||||||
config_val = config.instance.get(option)
|
config_val = config.instance.get(option)
|
||||||
if config_val == 'ask':
|
if config_val == 'ask':
|
||||||
@ -220,10 +223,20 @@ def feature_permission(url, option, msg, yes_action, no_action, abort_on):
|
|||||||
urlstr = None
|
urlstr = None
|
||||||
text = "Allow the website to {}?".format(msg)
|
text = "Allow the website to {}?".format(msg)
|
||||||
|
|
||||||
return message.confirm_async(
|
if blocking:
|
||||||
yes_action=yes_action, no_action=no_action,
|
answer = message.ask(abort_on=abort_on, title='Permission request',
|
||||||
cancel_action=no_action, abort_on=abort_on,
|
text=text, url=urlstr,
|
||||||
title='Permission request', text=text, url=urlstr)
|
mode=usertypes.PromptMode.yesno)
|
||||||
|
if answer:
|
||||||
|
yes_action()
|
||||||
|
else:
|
||||||
|
no_action()
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return message.confirm_async(
|
||||||
|
yes_action=yes_action, no_action=no_action,
|
||||||
|
cancel_action=no_action, abort_on=abort_on,
|
||||||
|
title='Permission request', text=text, url=urlstr)
|
||||||
elif config_val:
|
elif config_val:
|
||||||
yes_action()
|
yes_action()
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user