added missing files

This commit is contained in:
2022-02-08 09:26:09 -06:00
parent a544aab3b6
commit f4692fcbae
2 changed files with 48 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
{
"version": "0.2",
"ignorePaths": [],
"dictionaryDefinitions": [],
"dictionaries": [],
"words": [],
"ignoreWords": [],
"import": []
}
+39
View File
@@ -0,0 +1,39 @@
"""View module for handling requests about game types"""
from django.http import HttpResponseServerError
from rest_framework.viewsets import ViewSet
from rest_framework.response import Response
from rest_framework import serializers, status
from levelupapi.models import GameType
class GameTypeView(ViewSet):
"""Level up game types view"""
def retrieve(self, request, pk):
"""Handle GET requests for single game type
Returns:
Response -- JSON serialized game type
"""
game_type = GameType.objects.get(pk=pk)
serializer = GameTypeSerializer(game_type)
return Response(serializer.data)
def list(self, request):
"""Handle GET requests to get all game types
Returns:
Response -- JSON serialized list of game types
"""
game_types = GameType.objects.all()
serializer = GameTypeSerializer(game_types, many=True)
return Response(serializer.data)
class GameTypeSerializer(serializers.ModelSerializer):
"""JSON serializer for game types
"""
class Meta:
model = GameType
fields = ('id', 'label')