Fixes problem with penalty warning during superfast mode where inputting a non-full username would ask the user for a y/n answer forever
This commit is contained in:
parent
d9b6a3ab6d
commit
9122f5b579
|
@ -123,7 +123,7 @@ class Menu():
|
||||||
print 'Value must have length at most %d' % length_range[1]
|
print 'Value must have length at most %d' % length_range[1]
|
||||||
else:
|
else:
|
||||||
return result
|
return result
|
||||||
if timeout != 0:
|
if timeout:
|
||||||
print prompt,
|
print prompt,
|
||||||
rlist, _, _ = select([sys.stdin], [], [], timeout)
|
rlist, _, _ = select([sys.stdin], [], [], timeout)
|
||||||
if rlist:
|
if rlist:
|
||||||
|
@ -484,13 +484,14 @@ class ConfirmMenu(Menu):
|
||||||
options = {True: '[y]/n', False: 'y/[n]', None: 'y/n'}[self.default]
|
options = {True: '[y]/n', False: 'y/[n]', None: 'y/n'}[self.default]
|
||||||
while True:
|
while True:
|
||||||
result = self.input_str('%s (%s) ' % (self.prompt, options), timeout=self.timeout)
|
result = self.input_str('%s (%s) ' % (self.prompt, options), timeout=self.timeout)
|
||||||
result = result.lower()
|
result = result.lower().strip()
|
||||||
if result in ['y','yes']:
|
if result in ['y','yes']:
|
||||||
return True
|
return True
|
||||||
if result in ['n','no']:
|
elif result in ['n','no']:
|
||||||
return False
|
return False
|
||||||
if self.default != None and result == '':
|
elif self.default != None and result == '':
|
||||||
return self.default
|
return self.default
|
||||||
|
else:
|
||||||
print 'Please answer yes or no'
|
print 'Please answer yes or no'
|
||||||
|
|
||||||
|
|
||||||
|
@ -906,7 +907,7 @@ When finished, write an empty line to confirm the purchase.
|
||||||
print "THIS PURCHASE WILL AUTOMATICALLY BE PERFORMED IN 3 MINUTES!"
|
print "THIS PURCHASE WILL AUTOMATICALLY BE PERFORMED IN 3 MINUTES!"
|
||||||
return self.confirm(prompt=">", default=True, timeout=180)
|
return self.confirm(prompt=">", default=True, timeout=180)
|
||||||
else:
|
else:
|
||||||
return self.confirm(prompt=">")
|
return self.confirm(prompt=">", default=True)
|
||||||
|
|
||||||
|
|
||||||
def add_thing_to_purchase(self, thing):
|
def add_thing_to_purchase(self, thing):
|
||||||
|
@ -926,6 +927,7 @@ When finished, write an empty line to confirm the purchase.
|
||||||
Transaction(thing, purchase=self.purchase)
|
Transaction(thing, purchase=self.purchase)
|
||||||
elif isinstance(thing, Product):
|
elif isinstance(thing, Product):
|
||||||
PurchaseEntry(self.purchase, thing, 1)
|
PurchaseEntry(self.purchase, thing, 1)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _execute(self, initialContents=[]):
|
def _execute(self, initialContents=[]):
|
||||||
|
@ -974,7 +976,8 @@ When finished, write an empty line to confirm the purchase.
|
||||||
self.exit_confirm_msg='Abort purchase?'
|
self.exit_confirm_msg='Abort purchase?'
|
||||||
|
|
||||||
# Add the thing to our purchase object:
|
# Add the thing to our purchase object:
|
||||||
self.add_thing_to_purchase(thing)
|
if not self.add_thing_to_purchase(thing):
|
||||||
|
continue
|
||||||
|
|
||||||
# In superfast mode, we complete the purchase once we get a user:
|
# In superfast mode, we complete the purchase once we get a user:
|
||||||
if self.superfast_mode and isinstance(thing, User):
|
if self.superfast_mode and isinstance(thing, User):
|
||||||
|
|
Loading…
Reference in New Issue