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
030c1e56
Commit
030c1e56
authored
3 years ago
by
borzechof99
Browse files
Options
Downloads
Patches
Plain Diff
Change "pk" to "id"
parent
8089a2fd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
unisportomat/quiz/serializers.py
+6
-6
6 additions, 6 deletions
unisportomat/quiz/serializers.py
unisportomat/quiz/views.py
+1
-9
1 addition, 9 deletions
unisportomat/quiz/views.py
with
7 additions
and
15 deletions
unisportomat/quiz/serializers.py
+
6
−
6
View file @
030c1e56
...
@@ -12,7 +12,7 @@ class SportListSerializer(serializers.ModelSerializer):
...
@@ -12,7 +12,7 @@ class SportListSerializer(serializers.ModelSerializer):
class
Meta
:
class
Meta
:
model
=
Sport
model
=
Sport
fields
=
(
"
pk
"
,
"
name
"
,
"
url
"
,
"
criteria_ratings
"
)
fields
=
(
"
id
"
,
"
name
"
,
"
url
"
,
"
criteria_ratings
"
)
class
QuestionListSerializer
(
serializers
.
ModelSerializer
):
class
QuestionListSerializer
(
serializers
.
ModelSerializer
):
...
@@ -23,7 +23,7 @@ class QuestionListSerializer(serializers.ModelSerializer):
...
@@ -23,7 +23,7 @@ class QuestionListSerializer(serializers.ModelSerializer):
class
Meta
:
class
Meta
:
model
=
Question
model
=
Question
fields
=
(
"
pk
"
,
"
text
"
,
"
criterion
"
)
fields
=
(
"
id
"
,
"
text
"
,
"
criterion
"
)
class
CriterionListSerializer
(
serializers
.
ModelSerializer
):
class
CriterionListSerializer
(
serializers
.
ModelSerializer
):
...
@@ -33,7 +33,7 @@ class CriterionListSerializer(serializers.ModelSerializer):
...
@@ -33,7 +33,7 @@ class CriterionListSerializer(serializers.ModelSerializer):
class
Meta
:
class
Meta
:
model
=
Criterion
model
=
Criterion
fields
=
(
"
pk
"
,
"
name
"
)
fields
=
(
"
id
"
,
"
name
"
)
class
SmallSportListSerializer
(
serializers
.
BaseSerializer
):
class
SmallSportListSerializer
(
serializers
.
BaseSerializer
):
...
@@ -44,7 +44,7 @@ class SmallSportListSerializer(serializers.BaseSerializer):
...
@@ -44,7 +44,7 @@ class SmallSportListSerializer(serializers.BaseSerializer):
for
sport
,
boolean
in
sport_instances
:
for
sport
,
boolean
in
sport_instances
:
serialized_data
.
append
(
serialized_data
.
append
(
{
{
"
pk
"
:
sport
.
pk
,
"
id
"
:
sport
.
pk
,
"
name
"
:
sport
.
name
,
"
name
"
:
sport
.
name
,
"
url
"
:
sport
.
url
,
"
url
"
:
sport
.
url
,
"
is_filled
"
:
boolean
,
"
is_filled
"
:
boolean
,
...
@@ -59,7 +59,7 @@ class SingleSportSerializer(serializers.BaseSerializer):
...
@@ -59,7 +59,7 @@ class SingleSportSerializer(serializers.BaseSerializer):
serialized_data
=
{}
serialized_data
=
{}
serialized_data
[
"
pk
"
]
=
sport
.
pk
serialized_data
[
"
id
"
]
=
sport
.
pk
serialized_data
[
"
name
"
]
=
sport
.
name
serialized_data
[
"
name
"
]
=
sport
.
name
serialized_data
[
"
url
"
]
=
sport
.
url
serialized_data
[
"
url
"
]
=
sport
.
url
...
@@ -68,7 +68,7 @@ class SingleSportSerializer(serializers.BaseSerializer):
...
@@ -68,7 +68,7 @@ class SingleSportSerializer(serializers.BaseSerializer):
for
criterion
in
sport
.
criteria_ratings
.
iterator
():
for
criterion
in
sport
.
criteria_ratings
.
iterator
():
criterion_data
=
{}
criterion_data
=
{}
criterion_data
[
"
pk
"
]
=
criterion
.
pk
criterion_data
[
"
id
"
]
=
criterion
.
pk
criterion_data
[
"
name
"
]
=
criterion
.
name
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
# The iterator iterates over the Criterions connected, and not the criterion connection itself, so we need to get that one again
...
...
This diff is collapsed.
Click to expand it.
unisportomat/quiz/views.py
+
1
−
9
View file @
030c1e56
...
@@ -128,7 +128,7 @@ class SmallSportListView(viewsets.ViewSet):
...
@@ -128,7 +128,7 @@ class SmallSportListView(viewsets.ViewSet):
for
criterion
in
data_dict
[
"
criteria
"
]:
for
criterion
in
data_dict
[
"
criteria
"
]:
new_sport
.
rate
(
new_sport
.
rate
(
Criterion
.
objects
.
get
(
pk
=
criterion
[
"
pk
"
]),
criterion
[
"
value
"
]
Criterion
.
objects
.
get
(
pk
=
criterion
[
"
id
"
]),
criterion
[
"
value
"
]
)
)
new_sport
.
save
()
new_sport
.
save
()
...
@@ -171,11 +171,3 @@ class SmallSportListView(viewsets.ViewSet):
...
@@ -171,11 +171,3 @@ class SmallSportListView(viewsets.ViewSet):
def
destroy
(
self
,
request
,
pk
=
None
):
def
destroy
(
self
,
request
,
pk
=
None
):
return
Response
({
"
test
"
:
"
Removing a Single Entry
"
})
return
Response
({
"
test
"
:
"
Removing a Single Entry
"
})
# Dev Notes:
# - This is a singular APIView which isn't meant to expose complete lists
# - It cannot be written into the Router, as it isn't a Viewset, so it is written directly into the urls.py's urlspatterns like this:
# path(r"api/admin/single-small-sport-list", views.SmallSportListAPIView.as_view())
# - The API isn't in the list in /api/admin because of that, but needs to be called manually here:
# http://localhost:8000/api/admin/single-small-sport-list
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