#NEWLINE# def get_or_create_worker( worker_id ) : #NEWLINE# #INDENT# if ( user_obj is None ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# daemo_username = ( 'mturk.' + string . lower ( worker_id ) ) #NEWLINE# user = get_model_or_none ( User , username = daemo_username ) #NEWLINE# if ( user is None ) : #NEWLINE# #INDENT# user_obj = User . objects . create ( username = daemo_username , email = ( daemo_username + '@daemo.stanford.edu' ) , password = make_password ( generate_random_id ( ) ) , is_active = False ) #NEWLINE# profile_obj = UserProfile . objects . create ( user = user_obj ) #NEWLINE# worker_obj = Worker . objects . create ( profile = profile_obj , alias = daemo_username , scope = 'mturk' ) #NEWLINE# return worker_obj #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return user . userprofile . worker