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

Add TODOs

parent b1db1a38
No related branches found
No related tags found
No related merge requests found
......@@ -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):
......
......@@ -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
......
......@@ -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)
......
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