Skip to content
Snippets Groups Projects
Commit 030c1e56 authored by borzechof99's avatar borzechof99 :whale2:
Browse files

Change "pk" to "id"

parent 8089a2fd
No related branches found
No related tags found
No related merge requests found
...@@ -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
......
...@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment