Ejemplo n.º 1
0
 def put(self, request, pk, format=None):
     skill = self.get_object(pk)
     serializer = SkillSerializer(skill, data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 2
0
 def post(self, request, character_pk=None):
     data = {**request.data, "character": character_pk}
     skill_serializer = SkillSerializer(data=data,
                                        context={'request': request})
     if skill_serializer.is_valid():
         skill_serializer.save()
         return Response(skill_serializer.data,
                         status=status.HTTP_201_CREATED)
     return Response(skill_serializer.errors,
                     status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 3
0
 def patch(self, request, character_pk=None, skill_pk=None, format=None):
     skill_instance = get_skill_or_none(character_pk, skill_pk)
     if skill_instance:
         skill_serializer = SkillSerializer(instance=skill_instance,
                                            data=request.data,
                                            context={'request': request},
                                            partial=True)
         if skill_serializer.is_valid():
             skill_serializer.save()
             return Response(skill_serializer.data,
                             status=status.HTTP_200_OK)
         return Response(skill_serializer.errors,
                         status=status.HTTP_400_BAD_REQUEST)
     return SKILL_DOES_NOT_EXIST_RESPONSE
Ejemplo n.º 4
0
 def get(self, request, character_pk=None):
     return Response(SkillSerializer(
         Skill.objects.filter(character__id=character_pk),
         many=True,
         context={
             'request': request
         }).data,
                     status=status.HTTP_200_OK)
Ejemplo n.º 5
0
 def get(self, request, character_pk=None, skill_pk=None, format=None):
     skill_instance = get_skill_or_none(character_pk, skill_pk)
     if skill_instance:
         return Response(SkillSerializer(instance=skill_instance,
                                         many=False,
                                         context={
                                             'request': request
                                         }).data,
                         status=status.HTTP_200_OK)
     return SKILL_DOES_NOT_EXIST_RESPONSE
Ejemplo n.º 6
0
def skillDetail(request, pk):
    queryset = Skill.objects.get(id=pk)
    serializer = SkillSerializer(queryset, many=False)
    return Response(serializer.data)
Ejemplo n.º 7
0
def skillList(request):
    queryset = Skill.objects.all()
    serializer = SkillSerializer(queryset, many=True)
    return Response(serializer.data)
Ejemplo n.º 8
0
 def get(self, request, pk, format=None):
     skill = self.get_object(pk)
     serializer = SkillSerializer(skill)
     return Response(serializer.data)