Exemple #1
0
 def update(self, request, user__username=None, *args, **kwargs):
     serializer = UserProfileSerializer(instance=request.user.profile, data=request.data, partial=True)
     if serializer.is_valid():
         serializer.update()
         return Response({'status': 'updated profile'})
     else:
         raise serializers.ValidationError(detail=serializer.errors)
Exemple #2
0
 def update_profile(self, request, user__username=None):
     serializer = UserProfileSerializer(instance=self.get_object(),data=request.data)
     if serializer.is_valid():
         serializer.update()
         return Response({'status': 'updated profile'})
     else:
         return Response(serializer.errors,
                         status=status.HTTP_400_BAD_REQUEST)
Exemple #3
0
 def update_profile(self, request, user__username=None):
     serializer = UserProfileSerializer(instance=self.get_object(),
                                        data=request.data)
     if serializer.is_valid():
         serializer.update()
         return Response({'status': 'updated profile'})
     else:
         return Response(serializer.errors,
                         status=status.HTTP_400_BAD_REQUEST)
    def update(self, request, user__username=None, *args, **kwargs):
        if 'user' in request.data and 'email' in request.data['user'] and \
                request.user.email == request.data['user']['email']:
            del request.data['user']['email']

        serializer = UserProfileSerializer(instance=request.user.profile, data=request.data, partial=True)
        if serializer.is_valid():
            serializer.update()
            return Response({'status': 'updated profile'})
        else:
            raise serializers.ValidationError(detail=serializer.errors)
Exemple #5
0
 def create(self, request, *args, **kwargs):
     serializer = UserProfileSerializer(data=request.data)
     if serializer.is_valid():
         serializer.create()
         return Response(serializer.validated_data)
     return Response(serializer.errors, status.HTTP_400_BAD_REQUEST)
 def create(self, request, *args, **kwargs):
     serializer = UserProfileSerializer(data=request.data)
     if serializer.is_valid():
         serializer.create()
         return Response(serializer.validated_data)
     return Response(serializer.errors, status.HTTP_400_BAD_REQUEST)