def dissociate_answered_survey(account_id, source_id, sample_id, survey_id, token_info): _validate_account_access(token_info, account_id) with Transaction() as t: answers_repo = SurveyAnswersRepo(t) answers_repo.dissociate_answered_survey_from_sample( account_id, source_id, sample_id, survey_id) t.commit() return '', 204
def dissociate_sample(account_id, source_id, sample_id, token_info): _validate_account_access(token_info, account_id) with Transaction() as t: answers_repo = SurveyAnswersRepo(t) answered_survey_ids = answers_repo.list_answered_surveys_by_sample( account_id, source_id, sample_id) for curr_answered_survey_id in answered_survey_ids: answers_repo.dissociate_answered_survey_from_sample( account_id, source_id, sample_id, curr_answered_survey_id) sample_repo = SampleRepo(t) sample_repo.dissociate_sample(account_id, source_id, sample_id) t.commit() return '', 204
def delete_dummy_answered_surveys_from_source_with_t( t, dummy_acct_id, dummy_source_id, sample_ids, survey_answers_repo=None): if survey_answers_repo is None: survey_answers_repo = SurveyAnswersRepo(t) answers = survey_answers_repo.list_answered_surveys( dummy_acct_id, dummy_source_id) for survey_id in answers: for curr_sample_id in sample_ids: # dissociate this survey from any used sample try: survey_answers_repo.dissociate_answered_survey_from_sample( dummy_acct_id, dummy_source_id, curr_sample_id, survey_id) except werkzeug.exceptions.NotFound: pass # Now delete the answered survey survey_answers_repo.delete_answered_survey( dummy_acct_id, survey_id)