Ejemplo n.º 1
0
    def create():
        try:
            data = request.json
            task = models.Task.from_dict(data)
        except TypeError as e:
            return make_err_response(f'Invalid task data: {e}')

        created = storage.tasks.create_task(task)
        events.init_scoreboard()
        return jsonify(created.to_dict()), 201
Ejemplo n.º 2
0
    def update(team_id):
        try:
            data = request.json
            data['id'] = team_id
            team = models.Team.from_dict(request.json)
        except TypeError as e:
            return make_err_response(f'Invalid team data: {e}')

        updated = storage.teams.update_team(team)
        events.init_scoreboard()
        return jsonify(updated.to_dict())
Ejemplo n.º 3
0
    def create():
        try:
            data = request.json
            data['token'] = models.Team.generate_token()
            team = models.Team.from_dict(data)
        except TypeError as e:
            return make_err_response(f'Invalid team data: {e}')

        created = storage.teams.create_team(team)
        events.init_scoreboard()
        return jsonify(created.to_dict()), 201
Ejemplo n.º 4
0
    def update(task_id):
        try:
            data = request.json
            data['id'] = task_id
            task = models.Task.from_dict(request.json)
        except TypeError as e:
            return make_err_response(f'Invalid task data: {e}')

        updated = storage.tasks.update_task(task)
        events.init_scoreboard()
        return jsonify(updated.to_dict())
Ejemplo n.º 5
0
 def destroy(team_id):
     storage.teams.delete_team(team_id)
     events.init_scoreboard()
     return jsonify('ok')
Ejemplo n.º 6
0
 def destroy(task_id):
     storage.tasks.delete_task(task_id)
     events.init_scoreboard()
     return jsonify('ok')