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
0dfec37b
Commit
0dfec37b
authored
4 years ago
by
Josef Olsson
Browse files
Options
Downloads
Patches
Plain Diff
Commented question answer API
parent
9bccf62a
No related branches found
No related tags found
1 merge request
!130
Resolve "Comment apis"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/app/apis/answers.py
+17
-2
17 additions, 2 deletions
server/app/apis/answers.py
with
17 additions
and
2 deletions
server/app/apis/answers.py
+
17
−
2
View file @
0dfec37b
"""
All API calls concerning question answers.
Default route: /api/competitions/<competition_id>/teams/<team_id>/answers
"""
import
app.database.controller
as
dbc
from
app.apis
import
item_response
,
list_response
,
protect_route
from
app.core.dto
import
QuestionAnswerDTO
from
flask_restx
import
Resource
from
flask_restx
import
reqparse
from
app.core.parsers
import
sentinel
from
flask_restx
import
Resource
,
reqparse
api
=
QuestionAnswerDTO
.
api
schema
=
QuestionAnswerDTO
.
schema
...
...
@@ -24,11 +28,15 @@ answer_parser_edit.add_argument("score", type=int, default=sentinel, location="j
class
QuestionAnswerList
(
Resource
):
@protect_route
(
allowed_roles
=
[
"
*
"
],
allowed_views
=
[
"
*
"
])
def
get
(
self
,
competition_id
,
team_id
):
"""
Gets the all question answers that the specified team has given.
"""
items
=
dbc
.
get
.
question_answer_list
(
competition_id
,
team_id
)
return
list_response
(
list_schema
.
dump
(
items
))
@protect_route
(
allowed_roles
=
[
"
*
"
],
allowed_views
=
[
"
*
"
])
def
post
(
self
,
competition_id
,
team_id
):
"""
Posts a new question answer to the specified question.
"""
args
=
answer_parser_add
.
parse_args
(
strict
=
True
)
item
=
dbc
.
add
.
question_answer
(
**
args
,
team_id
=
team_id
)
return
item_response
(
schema
.
dump
(
item
))
...
...
@@ -39,12 +47,19 @@ class QuestionAnswerList(Resource):
class
QuestionAnswers
(
Resource
):
@protect_route
(
allowed_roles
=
[
"
*
"
],
allowed_views
=
[
"
*
"
])
def
get
(
self
,
competition_id
,
team_id
,
answer_id
):
"""
Gets the specified question answer.
"""
item
=
dbc
.
get
.
question_answer
(
competition_id
,
team_id
,
answer_id
)
return
item_response
(
schema
.
dump
(
item
))
@protect_route
(
allowed_roles
=
[
"
*
"
],
allowed_views
=
[
"
*
"
])
def
put
(
self
,
competition_id
,
team_id
,
answer_id
):
"""
Edits the specified question answer.
"""
args
=
answer_parser_edit
.
parse_args
(
strict
=
True
)
item
=
dbc
.
get
.
question_answer
(
competition_id
,
team_id
,
answer_id
)
item
=
dbc
.
edit
.
default
(
item
,
**
args
)
return
item_response
(
schema
.
dump
(
item
))
# No need to delete an answer. It only needs to be deleted
# together with the question or the team.
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