Example #1
0
def do_all(task, timestamp=None, modeltype=None):
    next_start = ""
    if timestamp is not None:
        next_start = timestamp

    while next_start is not None:
        content_items, next_start, prev_start = get_content_by_date(next_start)
        for item in content_items:
            path = item['full_path']
            timestamp = item['full_timestamp']
            for existing_type in item['metadata']['types'].iterkeys():
                if modeltype is None or modeltype == existing_type:
                    do_task(task, path, existing_type, timestamp, item['metadata'])
Example #2
0
def update_entire_search_index():
    SOLR_URL = getattr(settings, 'SOLR_WRITE_URL')
    SOLR_CONNECTION = None if SOLR_URL is None else pysolr.Solr(SOLR_URL)
    
    if SOLR_CONNECTION is None:
        return 0
    
    (content_items, older_start, newer_start) = get_content_by_date(start="", limit=2000000)
    
    items_to_insert = []
    for item in content_items:
        items_to_insert.append(item_to_search_fields(item))
    
    SOLR_CONNECTION.delete(q='*:*')
    SOLR_CONNECTION.add(items_to_insert)
    return len(items_to_insert)
Example #3
0
def browse(request):
    start = request.GET.get('start', '')
    view = request.GET.get('view', 'icon')
    try: count = int(request.GET.get('count', 25))
    except ValueError: count = 25
    try: reverse = bool(int(request.GET.get('reverse', True)))
    except ValueError: reverse = True

    if count > 100:
        count = 100

    (content_items, older_start, newer_start) = get_content_by_date(start=start, limit=count, reverse=reverse)
    view_params = {
        'content_items': content_items,
        'older_start': older_start,
        'newer_start': newer_start,
        'get_params': request.GET,
        'view': view
    }
    return render_to_response('content/browse.html', view_params, context_instance = RequestContext(request))
Example #4
0
def browse_json(request, start=""):
    (content_items, older_start, newer_start) = get_content_by_date(start=start)
    view_params = {'content_items': content_items, 'next_start': older_start, 'previous_start': newer_start}
    response = HttpResponse(simplejson.dumps(view_params, default=json_handler, indent=4), mimetype='application/json')
    response['Access-Control-Allow-Origin'] = '*'
    return response
Example #5
0
def compare_progressive(request):
    (content_items, older_start, newer_start) = get_content_by_date(start="", limit=5000)
    view_params = {
        'content_items': content_items,
    }
    return render_to_response('content/compare_progressive.html', view_params, context_instance = RequestContext(request))