示例#1
0
文件: views.py 项目: 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)
示例#2
0
文件: views.py 项目: 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)))
示例#3
0
文件: views.py 项目: 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)
示例#4
0
文件: views.py 项目: 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)
示例#5
0
 def current(self, request):
     user = UserUtils.get_user_from_request(request)
     serializer = self.get_serializer(user, many=False)
     return Response(serializer.data)
示例#6
0
文件: views.py 项目: gucciwu/gwq
 def current(self, request):
     user = UserUtils.get_user_from_request(request)
     self.queryset = User.objects.filter(id=user.id)