#NEWLINE# def get_device( self , step = None ) : #NEWLINE# #INDENT# '\n        Returns the OTP device selected by the user, or his default device.\n        ' #NEWLINE# if ( not self . device_cache ) : #NEWLINE# #INDENT# challenge_device_id = self . request . POST . get ( 'challenge_device' , None ) #NEWLINE# if challenge_device_id : #NEWLINE# #INDENT# for device in backup_phones ( self . get_user ( ) ) : #NEWLINE# #INDENT# if ( device . persistent_id == challenge_device_id ) : #NEWLINE# #INDENT# self . device_cache = device #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( step == 'backup' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . device_cache = self . get_user ( ) . staticdevice_set . get ( name = 'backup' ) #NEWLINE# #UNINDENT# except StaticDevice . DoesNotExist : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# if ( not self . device_cache ) : #NEWLINE# #INDENT# self . device_cache = default_device ( self . get_user ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# return self . device_cache