From 30829366f835d7c4745175ae329c7f7b271af400 Mon Sep 17 00:00:00 2001
From: Josef Olsson <josol381@student.liu.se>
Date: Wed, 5 May 2021 23:37:37 +0200
Subject: [PATCH] Comment user API

---
 server/app/apis/slides.py |  2 +-
 server/app/apis/teams.py  |  2 +-
 server/app/apis/users.py  | 23 +++++++++++++++++++----
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/server/app/apis/slides.py b/server/app/apis/slides.py
index 945e1084..ee9689b5 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 from the specified competition. """
+        """ Gets 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 82b88567..913deeb7 100644
--- a/server/app/apis/teams.py
+++ b/server/app/apis/teams.py
@@ -26,7 +26,7 @@ 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. """
+        """ Gets all teams to the specified competition. """
 
         items = dbc.get.team_list(competition_id)
         return list_response(list_schema.dump(items))
diff --git a/server/app/apis/users.py b/server/app/apis/users.py
index dc26ac5b..7cff57c8 100644
--- a/server/app/apis/users.py
+++ b/server/app/apis/users.py
@@ -1,11 +1,15 @@
+"""
+All API calls concerning question alternatives.
+Default route: /api/users
+"""
+
 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 UserDTO
-from flask_jwt_extended import get_jwt_identity
-from flask_restx import Resource
-from flask_restx import inputs, reqparse
 from app.core.parsers import search_parser, sentinel
+from flask_jwt_extended import get_jwt_identity
+from flask_restx import Resource, inputs, reqparse
 
 api = UserDTO.api
 schema = UserDTO.schema
@@ -25,13 +29,14 @@ user_search_parser.add_argument("role_id", type=int, default=sentinel, location=
 
 
 def _edit_user(item_user, args):
+    """ Edits a user using the provided arguments. """
+
     email = args.get("email")
     name = args.get("name")
 
     if email:
         if dbc.get.user_exists(email):
             api.abort(codes.BAD_REQUEST, "Email is already in use")
-
     if name:
         args["name"] = args["name"].title()
 
@@ -42,11 +47,15 @@ def _edit_user(item_user, args):
 class UsersList(Resource):
     @protect_route(allowed_roles=["*"])
     def get(self):
+        """ Gets all users. """
+
         item = dbc.get.user(get_jwt_identity())
         return item_response(schema.dump(item))
 
     @protect_route(allowed_roles=["*"])
     def put(self):
+        """ Posts a new user using the specified arguments. """
+
         args = user_parser_edit.parse_args(strict=True)
         item = dbc.get.user(get_jwt_identity())
         item = _edit_user(item, args)
@@ -58,11 +67,15 @@ class UsersList(Resource):
 class Users(Resource):
     @protect_route(allowed_roles=["*"])
     def get(self, ID):
+        """ Gets the specified user. """
+
         item = dbc.get.user(ID)
         return item_response(schema.dump(item))
 
     @protect_route(allowed_roles=["Admin"])
     def put(self, ID):
+        """ Edits the specified team using the provided arguments. """
+
         args = user_parser_edit.parse_args(strict=True)
         item = dbc.get.user(ID)
         item = _edit_user(item, args)
@@ -73,6 +86,8 @@ class Users(Resource):
 class UserSearch(Resource):
     @protect_route(allowed_roles=["*"])
     def get(self):
+        """ Finds a specific user based on the provided arguments. """
+
         args = user_search_parser.parse_args(strict=True)
         items, total = dbc.search.user(**args)
         return list_response(list_schema.dump(items), total)
-- 
GitLab