def post(self, survey_id: str):
        data = get_json_request_body(self)

        if data.get('survey_id', None) != survey_id:
            reason = validation_message('submission', 'survey_id', 'invalid')
            raise tornado.web.HTTPError(422, reason=reason)
        try:
            self.write(submission_api.submit(self.db, data))
            self.set_status(201)
        except KeyError as e:
            reason = validation_message('submission', str(e), 'missing_field')
            raise tornado.web.HTTPError(422, reason=reason)
        except IncorrectQuestionIdError:
            reason = validation_message('submission', 'question_id', 'invalid')
            raise tornado.web.HTTPError(422, reason=reason)
Beispiel #2
0
 def post(self, survey_id: str):
     body = get_json_request_body(self)
     subs = body.get('submitters', None)
     filters = body.get('filters', None)
     order_by = body.get('order_by', None)
     direction = body.get('direction', 'ASC')
     limit = body.get('limit', None)
     response = submission_api.get_all(
         self.db,
         self.get_email(),
         survey_id=survey_id,
         submitters=subs,
         filters=filters,
         order_by=order_by,
         direction=direction,
         limit=limit
     )
     self.write(response)
Beispiel #3
0
 def post(self):
     data = get_json_request_body(self)
     self.write(survey_api.create(self.db, data))
     self.set_status(201)
Beispiel #4
0
 def post(self):
     data = get_json_request_body(self)
     self.write(user_api.generate_token(self.db, data))