def _get_workflow_model(team_submission_uuid): """ Returns the `TeamAssessmentWorkflow` model associated with the given `team_submission_uuid`. Raises: AssessmentWorkflowRequestError for incorrect arguments AssessmentWorkflowNotFoundError when workflow not found AssessmentWorkflowInternalError on error """ if not isinstance(team_submission_uuid, str): raise AssessmentWorkflowRequestError("team_submission_uuid must be a string") try: team_workflow = TeamAssessmentWorkflow.get_by_team_submission_uuid(team_submission_uuid) except Exception as exc: err_msg = ( "Could not get team assessment workflow with team_submission_uuid {uuid} due to error: {exc}" ).format(uuid=team_submission_uuid, exc=exc) logger.exception(err_msg) raise AssessmentWorkflowInternalError(err_msg) if team_workflow is None: err_msg = ( "No team assessment workflow matching team_submission_uuid {uuid}" ).format(uuid=team_submission_uuid) raise AssessmentWorkflowNotFoundError(err_msg) return team_workflow
def is_workflow_cancelled(team_submission_uuid): """ Check if the team assessment workflow is cancelled """ try: workflow = TeamAssessmentWorkflow.get_by_team_submission_uuid(team_submission_uuid) return workflow.is_cancelled if workflow else False except AssessmentWorkflowError: return False