Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
teknikattan-scoring-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tddd96-grupp1
teknikattan-scoring-system
Commits
30829366
Commit
30829366
authored
4 years ago
by
Josef Olsson
Browse files
Options
Downloads
Patches
Plain Diff
Comment user API
parent
8053980f
No related branches found
No related tags found
1 merge request
!130
Resolve "Comment apis"
Pipeline
#44256
passed
4 years ago
Stage: setup
Stage: test
Stage: report
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/app/apis/slides.py
+1
-1
1 addition, 1 deletion
server/app/apis/slides.py
server/app/apis/teams.py
+1
-1
1 addition, 1 deletion
server/app/apis/teams.py
server/app/apis/users.py
+19
-4
19 additions, 4 deletions
server/app/apis/users.py
with
21 additions
and
6 deletions
server/app/apis/slides.py
+
1
−
1
View file @
30829366
...
@@ -26,7 +26,7 @@ slide_parser_edit.add_argument("background_image_id", default=sentinel, type=int
...
@@ -26,7 +26,7 @@ slide_parser_edit.add_argument("background_image_id", default=sentinel, type=int
class
SlidesList
(
Resource
):
class
SlidesList
(
Resource
):
@protect_route
(
allowed_roles
=
[
"
*
"
])
@protect_route
(
allowed_roles
=
[
"
*
"
])
def
get
(
self
,
competition_id
):
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
)
items
=
dbc
.
get
.
slide_list
(
competition_id
)
return
list_response
(
list_schema
.
dump
(
items
))
return
list_response
(
list_schema
.
dump
(
items
))
...
...
This diff is collapsed.
Click to expand it.
server/app/apis/teams.py
+
1
−
1
View file @
30829366
...
@@ -26,7 +26,7 @@ team_parser_edit.add_argument("name", type=str, default=sentinel, location="json
...
@@ -26,7 +26,7 @@ team_parser_edit.add_argument("name", type=str, default=sentinel, location="json
class
TeamsList
(
Resource
):
class
TeamsList
(
Resource
):
@protect_route
(
allowed_roles
=
[
"
*
"
])
@protect_route
(
allowed_roles
=
[
"
*
"
])
def
get
(
self
,
competition_id
):
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
)
items
=
dbc
.
get
.
team_list
(
competition_id
)
return
list_response
(
list_schema
.
dump
(
items
))
return
list_response
(
list_schema
.
dump
(
items
))
...
...
This diff is collapsed.
Click to expand it.
server/app/apis/users.py
+
19
−
4
View file @
30829366
"""
All API calls concerning question alternatives.
Default route: /api/users
"""
import
app.core.http_codes
as
codes
import
app.core.http_codes
as
codes
import
app.database.controller
as
dbc
import
app.database.controller
as
dbc
from
app.apis
import
item_response
,
list_response
,
protect_route
from
app.apis
import
item_response
,
list_response
,
protect_route
from
app.core.dto
import
UserDTO
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
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
api
=
UserDTO
.
api
schema
=
UserDTO
.
schema
schema
=
UserDTO
.
schema
...
@@ -25,13 +29,14 @@ user_search_parser.add_argument("role_id", type=int, default=sentinel, location=
...
@@ -25,13 +29,14 @@ user_search_parser.add_argument("role_id", type=int, default=sentinel, location=
def
_edit_user
(
item_user
,
args
):
def
_edit_user
(
item_user
,
args
):
"""
Edits a user using the provided arguments.
"""
email
=
args
.
get
(
"
email
"
)
email
=
args
.
get
(
"
email
"
)
name
=
args
.
get
(
"
name
"
)
name
=
args
.
get
(
"
name
"
)
if
email
:
if
email
:
if
dbc
.
get
.
user_exists
(
email
):
if
dbc
.
get
.
user_exists
(
email
):
api
.
abort
(
codes
.
BAD_REQUEST
,
"
Email is already in use
"
)
api
.
abort
(
codes
.
BAD_REQUEST
,
"
Email is already in use
"
)
if
name
:
if
name
:
args
[
"
name
"
]
=
args
[
"
name
"
].
title
()
args
[
"
name
"
]
=
args
[
"
name
"
].
title
()
...
@@ -42,11 +47,15 @@ def _edit_user(item_user, args):
...
@@ -42,11 +47,15 @@ def _edit_user(item_user, args):
class
UsersList
(
Resource
):
class
UsersList
(
Resource
):
@protect_route
(
allowed_roles
=
[
"
*
"
])
@protect_route
(
allowed_roles
=
[
"
*
"
])
def
get
(
self
):
def
get
(
self
):
"""
Gets all users.
"""
item
=
dbc
.
get
.
user
(
get_jwt_identity
())
item
=
dbc
.
get
.
user
(
get_jwt_identity
())
return
item_response
(
schema
.
dump
(
item
))
return
item_response
(
schema
.
dump
(
item
))
@protect_route
(
allowed_roles
=
[
"
*
"
])
@protect_route
(
allowed_roles
=
[
"
*
"
])
def
put
(
self
):
def
put
(
self
):
"""
Posts a new user using the specified arguments.
"""
args
=
user_parser_edit
.
parse_args
(
strict
=
True
)
args
=
user_parser_edit
.
parse_args
(
strict
=
True
)
item
=
dbc
.
get
.
user
(
get_jwt_identity
())
item
=
dbc
.
get
.
user
(
get_jwt_identity
())
item
=
_edit_user
(
item
,
args
)
item
=
_edit_user
(
item
,
args
)
...
@@ -58,11 +67,15 @@ class UsersList(Resource):
...
@@ -58,11 +67,15 @@ class UsersList(Resource):
class
Users
(
Resource
):
class
Users
(
Resource
):
@protect_route
(
allowed_roles
=
[
"
*
"
])
@protect_route
(
allowed_roles
=
[
"
*
"
])
def
get
(
self
,
ID
):
def
get
(
self
,
ID
):
"""
Gets the specified user.
"""
item
=
dbc
.
get
.
user
(
ID
)
item
=
dbc
.
get
.
user
(
ID
)
return
item_response
(
schema
.
dump
(
item
))
return
item_response
(
schema
.
dump
(
item
))
@protect_route
(
allowed_roles
=
[
"
Admin
"
])
@protect_route
(
allowed_roles
=
[
"
Admin
"
])
def
put
(
self
,
ID
):
def
put
(
self
,
ID
):
"""
Edits the specified team using the provided arguments.
"""
args
=
user_parser_edit
.
parse_args
(
strict
=
True
)
args
=
user_parser_edit
.
parse_args
(
strict
=
True
)
item
=
dbc
.
get
.
user
(
ID
)
item
=
dbc
.
get
.
user
(
ID
)
item
=
_edit_user
(
item
,
args
)
item
=
_edit_user
(
item
,
args
)
...
@@ -73,6 +86,8 @@ class Users(Resource):
...
@@ -73,6 +86,8 @@ class Users(Resource):
class
UserSearch
(
Resource
):
class
UserSearch
(
Resource
):
@protect_route
(
allowed_roles
=
[
"
*
"
])
@protect_route
(
allowed_roles
=
[
"
*
"
])
def
get
(
self
):
def
get
(
self
):
"""
Finds a specific user based on the provided arguments.
"""
args
=
user_search_parser
.
parse_args
(
strict
=
True
)
args
=
user_search_parser
.
parse_args
(
strict
=
True
)
items
,
total
=
dbc
.
search
.
user
(
**
args
)
items
,
total
=
dbc
.
search
.
user
(
**
args
)
return
list_response
(
list_schema
.
dump
(
items
),
total
)
return
list_response
(
list_schema
.
dump
(
items
),
total
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment