Esempio n. 1
0
File: views.py Progetto: gucciwu/gwq
 def perform_create(self, serializer):
     user = UserUtils.get_user_from_request(self.request)
     instance = serializer.save(owner=user,
                                created_by=user,
                                modified_by=user)
     message = '%s added %s' % (user.username, str(instance))
     self.log_addition(user, instance, message)
Esempio n. 2
0
File: views.py Progetto: gucciwu/gwq
def current_user(request):
    """
    API endpoint that fetch current login user.
    """
    user = UserUtils.get_user_from_request(request)
    return Response(
        serializers.serialize('json', User.objects.filter(id=user.id)))
Esempio n. 3
0
File: views.py Progetto: gucciwu/gwq
 def perform_destroy(self, instance):
     instance.deleted = True
     user = UserUtils.get_user_from_request(self.request)
     instance.modified_by = user
     instance.modified_at = timezone.now()
     instance.save(force_update_deleted=True)
     message = '%s soft deleted %s' % (user.username, str(instance))
     self.log_deletion(user, instance, message)
Esempio n. 4
0
File: views.py Progetto: gucciwu/gwq
 def perform_update(self, serializer):
     instance = serializer.save()
     user = UserUtils.get_user_from_request(self.request)
     instance.modified_by = user
     instance.modified_at = timezone.now()
     instance.save()
     message = '%s changed %s' % (user.username, str(instance))
     self.log_change(user, instance, message)
Esempio n. 5
0
 def current(self, request):
     user = UserUtils.get_user_from_request(request)
     serializer = self.get_serializer(user, many=False)
     return Response(serializer.data)
Esempio n. 6
0
File: views.py Progetto: gucciwu/gwq
 def current(self, request):
     user = UserUtils.get_user_from_request(request)
     self.queryset = User.objects.filter(id=user.id)