def create_dummy_answered_survey(dummy_acct_id, dummy_source_id, survey_template_id=PRIMARY_SURVEY_TEMPLATE_ID, survey_answers_id=DUMMY_ANSWERED_SURVEY_ID, survey_model=None, dummy_sample_id=None): if survey_model is None: survey_model = DUMMY_SURVEY_ANSWERS_MODEL with Transaction() as t: survey_answers_repo = SurveyAnswersRepo(t) survey_answers_id = survey_answers_repo.submit_answered_survey( dummy_acct_id, dummy_source_id, localization.EN_US, survey_template_id, survey_model, survey_answers_id ) if dummy_sample_id is not None: survey_answers_repo.associate_answered_survey_with_sample( dummy_acct_id, dummy_source_id, dummy_sample_id, survey_answers_id) t.commit() return survey_answers_id
def associate_answered_survey(account_id, source_id, sample_id, body, token_info): _validate_account_access(token_info, account_id) with Transaction() as t: answers_repo = SurveyAnswersRepo(t) answers_repo.associate_answered_survey_with_sample( account_id, source_id, sample_id, body['survey_id']) t.commit() response = flask.Response() response.status_code = 201 response.headers['Location'] = '/api/accounts/%s' \ '/sources/%s' \ '/surveys/%s' % \ (account_id, source_id, body['survey_id']) return response