def user_training_status(user, complete=False): """ Query and optionally update the user's training status. Args: Returns: Raises: RuntimeError """ training_record = model_utils.get_training_record(user) if training_record: return True elif complete: training_record = TrainingRecord.objects.create(user=user) training_record.save() else: return False
def get_user_app_status(user): """ Returns the status of the app for the current user. The status determines which functions are active. Args: Returns: Raises: """ user_status = {} # Filled out demographic info user_status[ 'demographic_form_done'] = True if model_utils.get_demographic_data( user) else False # Completed training user_status['training_done'] = True if model_utils.get_training_record( user) else False # Translation sessions remaining next_session = get_next_session_for_user(user) user_status['translate_done'] = next_session == None if next_session: user_status['ui_mode'] = next_session.interface user_status['src_domain'] = next_session.src_document.domain # Should the UI show a break? user_status['show_break'] = False last_session = get_last_complete_session_for_user(user) if last_session: break_type = show_break(last_session, next_session) user_status['show_break'] = break_type != None if break_type: user_status['break_type'] = break_type # Filled out exit survey user_status['exit_form_done'] = True if model_utils.get_exit_data( user) else False return user_status
def get_user_app_status(user): """ Returns the status of the app for the current user. The status determines which functions are active. Args: Returns: Raises: """ user_status = {} # Filled out demographic info user_status['demographic_form_done'] = True if model_utils.get_demographic_data(user) else False # Completed training user_status['training_done'] = True if model_utils.get_training_record(user) else False # Translation sessions remaining next_session = get_next_session_for_user(user) user_status['translate_done'] = next_session == None if next_session: user_status['ui_mode'] = next_session.interface user_status['src_domain'] = next_session.src_document.domain # Should the UI show a break? user_status['show_break'] = False last_session = get_last_complete_session_for_user(user) if last_session: break_type = show_break(last_session, next_session) user_status['show_break'] = break_type != None if break_type: user_status['break_type'] = break_type # Filled out exit survey user_status['exit_form_done'] = True if model_utils.get_exit_data(user) else False return user_status