Beispiel #1
0
 def contact(self, request, *args, **kwargs):
     instance = self.get_object()
     serializer = ProfileContactSerializer(instance.profile,
                                           data=request.data)
     serializer.is_valid(raise_exception=True)
     serializer.save()
     data = UserDetailModelSerializer(instance).data
     return Response(data, status=status.HTTP_200_OK)
Beispiel #2
0
 def register(self, request):
     """CREATE  USER"""
     serializer = UserSignUpSerializer(data=request.data,
                                       context={'request': request})
     serializer.is_valid(raise_exception=True)
     user = serializer.save()
     data = UserDetailModelSerializer(user).data
     return Response(data, status=status.HTTP_201_CREATED)
Beispiel #3
0
 def update(self, request, *args, **kwargs):
     """UPDATE USER"""
     partial = kwargs.pop('partial', False)
     instance = self.get_object()
     serializer = UserUpdateModelSerializer(instance,
                                            data=request.data,
                                            partial=partial)
     serializer.is_valid(raise_exception=True)
     serializer.save()
     return Response(UserDetailModelSerializer(instance).data)
Beispiel #4
0
 def profilepicture(self, request, *args, **kwargs):
     instance = self.request.user
     serializer = ProfilePictureSerializer(instance.profile,
                                           data=request.data)
     serializer.is_valid(raise_exception=True)
     user = serializer.save()
     data = {
         'state': 1,
         'data': UserDetailModelSerializer(instance).data,
         'message': _("The user picture was uploaded ")
     }
     return Response(data, status=status.HTTP_200_OK)
Beispiel #5
0
 def credential(self, request):
     """Return credential to user"""
     user = self.request.user
     token = get_response_token(user.pk, False)
     data = {
         'state': 1,
         'data': {
             'user': UserDetailModelSerializer(user).data,
             'token': token
         },
         'message': ''
     }
     return Response(data, status=status.HTTP_200_OK)
Beispiel #6
0
 def login(self, request):
     """access to system"""
     serializer = UserLoginSerializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     user, token = serializer.save()
     data = {
         'state': 1,
         'data': {
             'user': UserDetailModelSerializer(user).data,
             'token': token
         },
         'message': ''
     }
     return Response(data, status=status.HTTP_200_OK)