def submit(connection: Connection, data: dict) -> dict: """ Create a submission with answers. :param connection: a SQLAlchemy connection :param data: representation of the submission (from json.loads) :return: the UUID of the submission in the database :raise RequiredQuestionSkipped: if there is no answer for a required question """ c = connection survey_id = data['survey_id'] required = {q.question_id for q in get_required(c, survey_id)} with c.begin(): submission_id = _create_submission(c, survey_id, required, data) email = get_email_address(c, survey_id) return get_one(c, submission_id, email=email)
def testGetEmailAddress(self): survey = connection.execute(survey_table.select().where( survey_table.c.survey_title == 'test_title')).first() self.assertEqual( get_email_address(connection, survey.survey_id), 'test_email')
def wrapper(self, question_id: str, *args): question = question_select(self.db, question_id) authorized_email = get_email_address(self.db, question.survey_id) if self.current_user != authorized_email: raise tornado.web.HTTPError(404) return method(self, question_id, *args)