Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Backend
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
swp-unisport
team-warumkeinrust
Backend
Commits
85899ce9
Commit
85899ce9
authored
3 years ago
by
borzechof99
Browse files
Options
Downloads
Patches
Plain Diff
Add TODOs
parent
b1db1a38
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
unisportomat/quiz/pagination.py
+0
-1
0 additions, 1 deletion
unisportomat/quiz/pagination.py
unisportomat/quiz/serializers.py
+1
-1
1 addition, 1 deletion
unisportomat/quiz/serializers.py
unisportomat/quiz/views.py
+4
-10
4 additions, 10 deletions
unisportomat/quiz/views.py
with
5 additions
and
12 deletions
unisportomat/quiz/pagination.py
+
0
−
1
View file @
85899ce9
...
...
@@ -5,7 +5,6 @@ or be given globally via settings.py.
"""
from
rest_framework.pagination
import
PageNumberPagination
from
rest_framework.response
import
Response
class
PageNumberWithPageSizePagination
(
PageNumberPagination
):
...
...
This diff is collapsed.
Click to expand it.
unisportomat/quiz/serializers.py
+
1
−
1
View file @
85899ce9
...
...
@@ -22,7 +22,6 @@ class QuestionListSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Question
fields
=
(
"
id
"
,
"
text
"
,
"
criterion
"
)
...
...
@@ -72,6 +71,7 @@ class SingleSportSerializer(serializers.BaseSerializer):
criterion_data
[
"
name
"
]
=
criterion
.
name
# The iterator iterates over the Criterions connected, and not the criterion connection itself, so we need to get that one again
# TODO: Use get_rating of the Sport object
criterion_data
[
"
value
"
]
=
CriterionRating
.
objects
.
get
(
criterion
=
criterion
.
pk
,
sport
=
sport
.
pk
).
rating
...
...
This diff is collapsed.
Click to expand it.
unisportomat/quiz/views.py
+
4
−
10
View file @
85899ce9
...
...
@@ -6,6 +6,7 @@ Defines the views for the API
from
rest_framework
import
viewsets
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
django.shortcuts
import
get_object_or_404
from
django.http
import
JsonResponse
from
.pagination
import
PageNumberWithPageSizePagination
...
...
@@ -92,6 +93,8 @@ class SmallSportListView(viewsets.ViewSet):
filled_criteria_pks
=
[]
# TODO: Change the way that unfilled Criteria are detected (look for value -1)
# TODO: is_filled as function of sport
# Get pks of Criteria which are connected to the sport
for
criterion
in
sport
.
criteria_ratings
.
iterator
():
filled_criteria_pks
.
append
(
criterion
.
pk
)
...
...
@@ -140,16 +143,7 @@ class SmallSportListView(viewsets.ViewSet):
# GET for api/admin/sport/<id>/
def
retrieve
(
self
,
request
,
pk
=
None
):
try
:
sport
=
Sport
.
objects
.
get
(
pk
=
pk
)
except
:
return
JsonResponse
(
{
"
status_code
"
:
404
,
"
error
"
:
f
"
No Sport with ID
{
pk
}
found
"
,
},
status
=
404
,
)
sport
=
get_object_or_404
(
Sport
,
pk
=
pk
)
return
Response
(
SingleSportSerializer
(
sport
).
data
)
...
...
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