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
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=[]))
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=[]) )
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=[]))
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=[]) )