Example #1
0
    def delete(cls, tournament_id, user_id):
        claims = get_jwt_claims()
        if not claims['is_admin']:
            return {'message': ADMIN_PERMISSION}, 401
        tournament = ScoreModel.find_by_id(tournament_id)
        member = ScoreModel.find_by_id(user_id)

        if tournament:
            if member:
                member.delete_from_db()
                return {"message": SUCCESS_DELETING}, 200
            return {"message": ITEM_NOT_FOUND}, 404
        return {"message": ITEM_NOT_FOUND}, 404
Example #2
0
    def get(self, quiz_id, score_id):
        score = ScoreModel.find_by_id(score_id)

        if score is None:
            return {"message": "No score found."}, 404

        return score.json(), 200
Example #3
0
    def delete(cls, user_id: int, tournament_id: int):

        score = ScoreModel.find_by_id(user_id, tournament_id)

        if not score:
            return {"message": ITEM_NOT_FOUND}, 404
        score.delete_from_db()
        return {"message": SUCCESS_DELETING}, 200
Example #4
0
    def delete(self, quiz_id, score_id):
        score = ScoreModel.find_by_id(score_id)

        if score is None:
            return {"message": "No score found."}, 404

        try:
            score.delete()
        except:
            return {"message": "An error occurred while deleting Score."}, 500

        return {"message": "Score deleted."}, 200
Example #5
0
    def put(self, quiz_id, score_id):
        data = parser.parse_args()

        score = ScoreModel.find_by_id(score_id)

        if score is None:
            new_score = ScoreModel(**data)
            try:
                new_score.save()

                return new_score.json(), 201
            except:
                return {"message": "An error occurred while inserting Score."}, 500
        try:
            score.update(**data)
        except:
            return {"message": "An error occurred while updating Score."}, 500

        return score.json(), 200
Example #6
0
    def put(cls, user_id: int, tournament_id: int):

        data = Score.parser.parse_args()
        score = ScoreModel.find_by_id(user_id, tournament_id)
        if score:
            score.has_own_game = data['has_own_game']
            score.end_terra_first = data['end_terra_first']
            score.end_terra_second = data['end_terra_second']
            score.status = data['status']
            score.group1 = data['group1']
            score.group2 = data['group2']
            score.pz1 = data['pz1']
            score.pz2 = data['pz2']
            score.pz3 = data['pz3']
        try:
            score.save_to_db()
        except:
            return {"message": ERROR_EDITING}, 500

        return score.json(), 200