예제 #1
0
def test_collection_for_for_owner():
    """
    Tests the for_owner Collection method
    """
    owner = UserFactory()
    collections = [CollectionFactory(owner=owner) for _ in range(5)]
    extra_collection = CollectionFactory()
    qset = Collection.for_owner(owner)
    assert qset.count() == 5
    assert list(qset) == sorted(collections,
                                key=lambda x: x.created_at,
                                reverse=True)
    assert extra_collection not in qset
예제 #2
0
def detail(request, repo, org, cid):
    collection = Collection.get(repo, org, cid)
    if not collection:
        raise Http404
    return render_to_response('ui/collections/detail.html', {
        'repo': repo,
        'org': org,
        'cid': cid,
        'object': collection,
        'entities': collection.entities(size=10),
    },
                              context_instance=RequestContext(request,
                                                              processors=[]))
예제 #3
0
def detail( request, repo, org, cid ):
    collection = Collection.get(repo, org, cid)
    if not collection:
        raise Http404
    return render_to_response(
        'ui/collections/detail.html',
        {
            'repo': repo,
            'org': org,
            'cid': cid,
            'object': collection,
            'entities': collection.entities(size=10),
        },
        context_instance=RequestContext(request, processors=[])
    )
예제 #4
0
def files(request, repo, org, cid):
    collection = Collection.get(repo, org, cid)
    if not collection:
        raise Http404
    paginator = Paginator(collection.files(size=elasticsearch.MAX_SIZE),
                          settings.RESULTS_PER_PAGE)
    page = paginator.page(request.GET.get('page', 1))
    return render_to_response('ui/collections/files.html', {
        'repo': repo,
        'org': org,
        'cid': cid,
        'object': collection,
        'paginator': paginator,
        'page': page,
    },
                              context_instance=RequestContext(request,
                                                              processors=[]))
예제 #5
0
def files( request, repo, org, cid ):
    collection = Collection.get(repo, org, cid)
    if not collection:
        raise Http404
    paginator = Paginator(collection.files(size=elasticsearch.MAX_SIZE), settings.RESULTS_PER_PAGE)
    page = paginator.page(request.GET.get('page', 1))
    return render_to_response(
        'ui/collections/files.html',
        {
            'repo': repo,
            'org': org,
            'cid': cid,
            'object': collection,
            'paginator': paginator,
            'page': page,
        },
        context_instance=RequestContext(request, processors=[])
    )