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
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())
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
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())
def destroy(team_id): storage.teams.delete_team(team_id) events.init_scoreboard() return jsonify('ok')
def destroy(task_id): storage.tasks.delete_task(task_id) events.init_scoreboard() return jsonify('ok')