def handle_delete(request): index_to_delete = request.POST['delete_index'] # Rule 1: Has to start with the ES_INDEX_PREFIX. if not index_to_delete.startswith(settings.ES_INDEX_PREFIX): raise DeleteError('"%s" is not a valid index name.' % index_to_delete) # Rule 2: Must be an existing index. indexes = [name for name, count in get_indexes()] if index_to_delete not in indexes: raise DeleteError('"%s" does not exist.' % index_to_delete) # Rule 3: Don't delete the READ index. if index_to_delete == es_utils.READ_INDEX: raise DeleteError('"%s" is the read index.' % index_to_delete) delete_index(index_to_delete) return HttpResponseRedirect(request.path)
def handle_delete(request): """Deletes an index""" index_to_delete = request.POST['delete_index'] # Rule 1: Has to start with the ES_INDEX_PREFIX. if not index_to_delete.startswith(settings.ES_INDEX_PREFIX): raise DeleteError('"%s" is not a valid index name.' % index_to_delete) # Rule 2: Must be an existing index. indexes = [name for name, count in get_indexes()] if index_to_delete not in indexes: raise DeleteError('"%s" does not exist.' % index_to_delete) # Rule 3: Don't delete the READ index. if index_to_delete == es_utils.READ_INDEX: raise DeleteError('"%s" is the read index.' % index_to_delete) delete_index(index_to_delete) return HttpResponseRedirect(request.path)
def teardown_indexes(self): es_utils.delete_index(es_utils.READ_INDEX)
def teardown_indexes(self): """Tear down WRITE_INDEX""" es_utils.delete_index(es_utils.WRITE_INDEX)