def put(self):
     """
     ---
     summary: Profile update
     description: Updates user profile data
     """
     return success_response()
Esempio n. 2
0
    def get(self):
        """
        ---
        summary: Service status
        description: Method to test that service is working, always returns success
        responses:
            200:
                description: OK
        """

        return success_response()
    def post(self):
        """
        ---
        summary: Logout
        description: Revokes JWT token
        responses:
          202:
            description: OK
        """
        jti = get_raw_jwt()['jti']

        if not application.orm.revoke_token_by_jti(jti):
            return fail_response('Something went wrong', code=500)

        return success_response(_data={'jti': jti}, code=202)
Esempio n. 4
0
    def put(self, args, submission_id):
        """
        ---
        summary: Test checkpoint
        description: Saves current answers for test
        parameters:
            - in: path
              required: true
              name: submission_id
              schema:
                  type: int
        requestBody:
            required: true
            content:
                application/json:
                  schema: TestsSubmissionsSchema
        responses:
            201:
                description: OK
            404:
                description: Not found
                content:
                    application/json:
                        schema: ErrorSchema
                        example:
                          message: [Test not found]

        """
        for answer in args['answers']:
            if application.orm.is_answer_exists(submission_id,
                                                answer.question_id):
                application.orm.update_answer(submission_id=submission_id,
                                              question_id=answer.question_id,
                                              answer=answer.answer,
                                              grade=answer.grade,
                                              comments=answer.comments)
            else:
                application.orm.add_answer(submission_id=submission_id,
                                           question_id=answer.question_id,
                                           answer=answer.answer)
        return success_response(msg="Answers saved")
    def post(self, test_id):
        """
        ---
        summary: Test start
        description: Starts picked test for user and creates empty submission checkpoint
        parameters:
            - in: path
              required: true
              name: test_id
              schema:
                  type: int
        responses:
            201:
                description: OK
        """
        user: Users = get_current_user()

        submission = application.orm.init_submission(candidate_id=user.id, test_id=test_id)
        if submission is None:
            return fail_response("Submission was not created", code=406)

        return success_response(msg=submission.id, code=201)