Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
 def get_profile(self, request):
     user_profiles = UserProfile.objects.all()
     serializer = UserProfileSerializer(user_profiles)
     return Response(serializer.data)
Exemplo n.º 6
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)
Exemplo n.º 7
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)