예제 #1
0
파일: models.py 프로젝트: 18600597055/hue
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
예제 #2
0
파일: models.py 프로젝트: bopopescu/hue-5
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
예제 #3
0
파일: api2.py 프로젝트: dulems/hue-1
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)
예제 #4
0
파일: api2.py 프로젝트: lorelib/hue
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)
예제 #5
0
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)