コード例 #1
0
ファイル: api2.py プロジェクト: ronwxy/hue
def delete_indexes(request):
  if request.method != 'POST':
    raise PopupException(_('POST request required.'))

  response = {'status': -1}

  indexes = json.loads(request.POST.get('indexes', '[]'))

  if not indexes:
    response['message'] = _('No indexes to remove.')
  else:
    searcher = CollectionController(request.user)

    for index in indexes:
      if index['type'] == 'collection':
        searcher.delete_collection(index['name'])
      elif index['type'] == 'alias':
        searcher.delete_alias(index['name'])
      else:
        LOG.warn('We could not delete: %s' % index)

    response['status'] = 0
    response['message'] = _('Indexes removed!')

  return JsonResponse(response)
コード例 #2
0
def indexes(request):
  searcher = CollectionController(request.user)
  indexes = searcher.get_indexes()
  
  for index in indexes:
    index['isSelected'] = False

  return render('indexes.mako', request, {
      'indexes_json': json.dumps(indexes),
  })
コード例 #3
0
ファイル: api2.py プロジェクト: ronwxy/hue
def delete_indexes(request):
    if request.method != 'POST':
        raise PopupException(_('POST request required.'))

    response = {'status': -1}

    indexes = json.loads(request.POST.get('indexes', '[]'))

    if not indexes:
        response['message'] = _('No indexes to remove.')
    else:
        searcher = CollectionController(request.user)

        for index in indexes:
            if index['type'] == 'collection':
                searcher.delete_collection(index['name'])
            elif index['type'] == 'alias':
                searcher.delete_alias(index['name'])
            else:
                LOG.warn('We could not delete: %s' % index)

        response['status'] = 0
        response['message'] = _('Indexes removed!')

    return JsonResponse(response)
コード例 #4
0
ファイル: api2.py プロジェクト: ronwxy/hue
def create_collection(request):
  if request.method != 'POST':
    raise PopupException(_('POST request required.'))

  response = {'status': -1}

  name = request.POST.get('name')

  if name:
    searcher = CollectionController(request.user)

    try:
      collection = searcher.create_collection(name,
                                              request.POST.get('fields', get_default_fields()),
                                              request.POST.get('uniqueKeyField', 'id'),
                                              request.POST.get('df', 'text'))

      response['status'] = 0
      response['collection'] = collection
      response['message'] = _('Collection created!')
    except Exception, e:
      response['message'] = _('Collection could not be created: %s') % e
コード例 #5
0
ファイル: api2.py プロジェクト: ronwxy/hue
def create_collection(request):
    if request.method != 'POST':
        raise PopupException(_('POST request required.'))

    response = {'status': -1}

    name = request.POST.get('name')

    if name:
        searcher = CollectionController(request.user)

        try:
            collection = searcher.create_collection(
                name, request.POST.get('fields', get_default_fields()),
                request.POST.get('uniqueKeyField', 'id'),
                request.POST.get('df', 'text'))

            response['status'] = 0
            response['collection'] = collection
            response['message'] = _('Collection created!')
        except Exception, e:
            response['message'] = _('Collection could not be created: %s') % e