def can_kill_job(self, user): if DISABLE_KILLING_JOBS.get(): return False if self.status.lower() not in ('running', 'pending', 'accepted'): return False if user.is_superuser: return True if can_modify_job(user.username, self): return True return user.username == self.user
def action(request): response = {'status': -1, 'message': ''} interface = json.loads(request.POST.get('interface')) app_ids = json.loads(request.POST.get('app_ids')) operation = json.loads(request.POST.get('operation')) if operation.get('action') == 'kill' and DISABLE_KILLING_JOBS.get(): return serve_403_error(request) response['operation'] = operation response.update(get_api(request.user, interface).action(app_ids, operation)) return JsonResponse(response)
def action(request, interface=None, action=None): response = {'status': -1, 'message': ''} interface = json.loads(request.POST.get('interface')) app_ids = json.loads(request.POST.get('app_ids')) operation = json.loads(request.POST.get('operation')) if operation.get('action') == 'kill' and DISABLE_KILLING_JOBS.get(): return serve_403_error(request) response['operation'] = operation response.update(get_api(request.user, interface).action(app_ids, operation)) return JsonResponse(response)
def jobs(request): response = {'status': -1} interface = json.loads(request.POST.get('interface')) filters = dict([ (key, value) for _filter in json.loads(request.POST.get('filters', '[]')) for key, value in _filter.items() if value ]) jobs = get_api(request.user, interface).apps(filters) response['disable_killing_jobs'] = DISABLE_KILLING_JOBS.get() response['apps'] = jobs['apps'] response['total'] = jobs.get('total') response['status'] = 0 return JsonResponse(response)