def post(self, request, *args, **kwargs): if 'username' in request.POST: username = request.POST['username'] if User.objects.filter(username=username).exists(): user = User.objects.get(username=username) self.data.update({ 'max_cpu': user.max_cores, 'max_time': user.max_cpu_time, 'used_time': float("%.2g" % user.used_cpu_time) }) return JsonRequest.post(self, request, *args, **kwargs)
def post(self, request, *args, **kwargs): if 'username' in request.POST and 'status' in request.POST: username = request.POST['username'] status = request.POST['status'] if User.objects.filter(username=username).exists(): user = User.objects.get(username=username) user.is_staff = (status == 'true') user.save() self.data.update({'result': 'ok'}) else: self.data.update({'result': 'err'}) else: self.data.update({'result': 'err'}) return JsonRequest.post(self, request, *args, **kwargs)
def __init__(self): JsonRequest.__init__(self)