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
8cbf0ccd
Commit
8cbf0ccd
authored
4 years ago
by
Victor Löfgren
Browse files
Options
Downloads
Patches
Plain Diff
Add edit question api call
parent
57a727ad
No related branches found
No related tags found
1 merge request
!55
Resolve "Add more api calls"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/app/apis/questions.py
+13
-7
13 additions, 7 deletions
server/app/apis/questions.py
server/app/core/controller/edit.py
+20
-0
20 additions, 0 deletions
server/app/core/controller/edit.py
with
33 additions
and
7 deletions
server/app/apis/questions.py
+
13
−
7
View file @
8cbf0ccd
...
...
@@ -42,7 +42,7 @@ list_schema = QuestionDTO.list_schema
@api.route
(
"
/
"
)
@api.param
(
"
CID
"
)
class
Competi
tionsList
(
Resource
):
class
Ques
tionsList
(
Resource
):
@jwt_required
def
post
(
self
,
CID
):
args
=
question_parser
.
parse_args
(
strict
=
True
)
...
...
@@ -66,12 +66,18 @@ class Questions(Resource):
item
=
Question
.
query
.
filter
(
Question
.
id
==
QID
).
first
()
return
item_response
(
schema
.
dump
(
item
))
# @jwt_required
# def put(self, QID):
# args = user_parser.parse_args(strict=True)
# item = Question.query.filter(Question.id == QID).first()
# item = edit_user(item, args)
# return item_response(schema.dump(item))
@jwt_required
def
put
(
self
,
CID
,
QID
):
args
=
question_parser
.
parse_args
(
strict
=
True
)
name
=
args
.
get
(
"
name
"
)
# total_score = args.get("total_score")
slide_id
=
args
.
get
(
"
slide_id
"
)
type_id
=
args
.
get
(
"
type_id
"
)
item_question
=
Question
.
query
.
filter
(
Question
.
id
==
QID
).
first
()
item_question
=
dbc
.
edit
.
question
(
item_question
,
name
=
name
,
slide_id
=
slide_id
,
type_id
=
type_id
)
return
item_response
(
schema
.
dump
(
item_question
))
# @api.route("/search")
...
...
This diff is collapsed.
Click to expand it.
server/app/core/controller/edit.py
+
20
−
0
View file @
8cbf0ccd
...
...
@@ -61,3 +61,23 @@ def user(item, name=None, email=None, city_id=None, role_id=None):
db
.
session
.
commit
()
db
.
session
.
refresh
(
item
)
return
item
def
question
(
item_question
,
name
=
None
,
total_score
=
None
,
type_id
=
None
,
slide_id
=
None
):
if
name
:
item_question
.
name
=
name
if
total_score
:
item_question
.
total_score
=
total_score
if
type_id
:
item_question
.
type_id
=
type_id
if
slide_id
:
item_question
.
slide_id
=
slide_id
db
.
session
.
commit
()
db
.
session
.
refresh
(
item_question
)
return
item_question
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