コード例 #1
0
ファイル: navigator_api.py プロジェクト: XueminZhu/hue
def add_tags(request):
    response = {'status': -1}

    api = NavigatorApi(request.user)
    entity_id = json.loads(request.POST.get('id', ''))
    tags = json.loads(request.POST.get('tags', []))

    is_allowed = request.user.has_hue_permission(action='write',
                                                 app='metadata')

    request.audit = {
        'allowed': is_allowed,
        'operation': 'NAVIGATOR_ADD_TAG',
        'operationText': 'Adding tags %s to entity %s' % (tags, entity_id)
    }

    if not entity_id or not tags or not isinstance(tags,
                                                   list) or not is_allowed:
        response['error'] = _(
            "add_tags requires an 'id' parameter and 'tags' parameter that is a non-empty list of tags"
        )
    else:
        response['entity'] = api.add_tags(entity_id, tags)
        response['status'] = 0

    return JsonResponse(response)
コード例 #2
0
ファイル: navigator_api.py プロジェクト: zkenstein/hue
def add_tags(request):
    api = NavigatorApi(request.user)
    entity_id = json.loads(request.POST.get('id', '""'))
    tags = json.loads(request.POST.get('tags', "[]"))

    is_allowed = request.user.has_hue_permission(action='write',
                                                 app='metadata')

    request.audit = {
        'allowed': is_allowed,
        'operation': 'NAVIGATOR_ADD_TAG',
        'operationText': 'Adding tags %s to entity %s' % (tags, entity_id)
    }

    if not is_allowed:
        raise Exception(
            "The user does not have proper Hue permissions to add Navigator tags."
        )
    if not entity_id:
        raise Exception(
            "Missing required parameter 'id' for the Hue add_tags API.")
    if not tags:
        raise Exception(
            "Missing required parameter 'tags' for the Hue add_tags API.")

    return JsonResponse(api.add_tags(entity_id, tags))
コード例 #3
0
def add_tags(request):
  response = {'status': -1}

  api = NavigatorApi()
  entity_id = json.loads(request.POST.get('id', ''))
  tags = json.loads(request.POST.get('tags', []))

  if not entity_id or not tags or not isinstance(tags, list):
    response['error'] = _("add_tags requires an 'id' parameter and 'tags' parameter that is a non-empty list of tags")
  else:
    response['entity'] = api.add_tags(entity_id, tags)
    response['status'] = 0

  return JsonResponse(response)
コード例 #4
0
ファイル: navigator_api.py プロジェクト: walter-woodall/hue
def add_tags(request):
  response = {'status': -1}

  api = NavigatorApi()
  entity_id = json.loads(request.POST.get('id', ''))
  tags = json.loads(request.POST.get('tags', []))

  if not entity_id or not tags or not isinstance(tags, list):
    response['error'] = _("add_tags requires an 'id' parameter and 'tags' parameter that is a non-empty list of tags")
  else:
    response['entity'] = api.add_tags(entity_id, tags)
    response['status'] = 0

  return JsonResponse(response)