예제 #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)
예제 #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)
예제 #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
예제 #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)
예제 #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
예제 #6
0
파일: skill.py 프로젝트: m0b1n/portofolio
def skillDetail(request, pk):
    queryset = Skill.objects.get(id=pk)
    serializer = SkillSerializer(queryset, many=False)
    return Response(serializer.data)
예제 #7
0
파일: skill.py 프로젝트: m0b1n/portofolio
def skillList(request):
    queryset = Skill.objects.all()
    serializer = SkillSerializer(queryset, many=True)
    return Response(serializer.data)
예제 #8
0
 def get(self, request, pk, format=None):
     skill = self.get_object(pk)
     serializer = SkillSerializer(skill)
     return Response(serializer.data)