Skip to content
Snippets Groups Projects
Commit 8053980f authored by Josef Olsson's avatar Josef Olsson
Browse files

Comment team API

parent 517bdfff
No related branches found
No related tags found
1 merge request!130Resolve "Comment apis"
......@@ -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))
......
"""
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment