diff --git a/server/app/apis/slides.py b/server/app/apis/slides.py index b44941bf8162a0f97c1673d3f5b27b04b47dd8ed..945e1084018b2df451aaba310014b96262929671 100644 --- a/server/app/apis/slides.py +++ b/server/app/apis/slides.py @@ -26,7 +26,7 @@ slide_parser_edit.add_argument("background_image_id", default=sentinel, type=int class SlidesList(Resource): @protect_route(allowed_roles=["*"]) def get(self, competition_id): - """ Gets the all slides to the specified competition. """ + """ Gets the all slides from the specified competition. """ items = dbc.get.slide_list(competition_id) return list_response(list_schema.dump(items)) diff --git a/server/app/apis/teams.py b/server/app/apis/teams.py index 71ca715d55d21de75f07db4241e5ef0bb14e1050..82b8856738c931a5fb2e7985d685c5e859337046 100644 --- a/server/app/apis/teams.py +++ b/server/app/apis/teams.py @@ -1,9 +1,14 @@ +""" +All API calls concerning question alternatives. +Default route: /api/competitions/<competition_id>/teams +""" + import app.core.http_codes as codes import app.database.controller as dbc from app.apis import item_response, list_response, protect_route from app.core.dto import TeamDTO -from flask_restx import Resource, reqparse from app.core.parsers import sentinel +from flask_restx import Resource, reqparse api = TeamDTO.api schema = TeamDTO.schema @@ -21,11 +26,15 @@ team_parser_edit.add_argument("name", type=str, default=sentinel, location="json class TeamsList(Resource): @protect_route(allowed_roles=["*"]) def get(self, competition_id): + """ Gets the all teams to the specified competition. """ + items = dbc.get.team_list(competition_id) return list_response(list_schema.dump(items)) @protect_route(allowed_roles=["*"]) def post(self, competition_id): + """ Posts a new team to the specified competition. """ + args = team_parser_add.parse_args(strict=True) item_team = dbc.add.team(args["name"], competition_id) return item_response(schema.dump(item_team)) @@ -36,18 +45,15 @@ class TeamsList(Resource): class Teams(Resource): @protect_route(allowed_roles=["*"]) def get(self, competition_id, team_id): + """ Gets the specified team. """ + item = dbc.get.team(competition_id, team_id) return item_response(schema.dump(item)) - @protect_route(allowed_roles=["*"]) - def delete(self, competition_id, team_id): - item_team = dbc.get.team(competition_id, team_id) - - dbc.delete.team(item_team) - return {}, codes.NO_CONTENT - @protect_route(allowed_roles=["*"]) def put(self, competition_id, team_id): + """ Edits the specified team using the provided arguments. """ + args = team_parser_edit.parse_args(strict=True) name = args.get("name") @@ -55,3 +61,12 @@ class Teams(Resource): item_team = dbc.edit.default(item_team, name=name, competition_id=competition_id) return item_response(schema.dump(item_team)) + + @protect_route(allowed_roles=["*"]) + def delete(self, competition_id, team_id): + """ Deletes the specified team. """ + + item_team = dbc.get.team(competition_id, team_id) + + dbc.delete.team(item_team) + return {}, codes.NO_CONTENT