def test_returns_only_collections_associated_with_theses(self): # Setup author = AuthorFactory.create() collection_1 = CollectionFactory.create(localidentifier='col1') collection_2 = CollectionFactory.create(localidentifier='col2') CollectionFactory.create(localidentifier='col3') ThesisFactory.create(localidentifier='thesis1', collection=collection_1, author=author) ThesisFactory.create(localidentifier='thesis2', collection=collection_2, author=author) # Run & check assert list(get_thesis_collections()) == [collection_1, collection_2, ]
def test_returns_only_collections_associated_with_theses(self): # Setup author = AuthorFactory.create() collection_1 = CollectionFactory.create(localidentifier='col1') collection_2 = CollectionFactory.create(localidentifier='col2') CollectionFactory.create(localidentifier='col3') ThesisFactory.create(localidentifier='thesis1', collection=collection_1, author=author) ThesisFactory.create(localidentifier='thesis2', collection=collection_2, author=author) # Run & check assert list(get_thesis_collections()) == [ collection_1, collection_2, ]
def get_context_data(self, **kwargs): context = super(ThesisHomeView, self).get_context_data(**kwargs) # Fetches the collections associated with theses. collections = get_thesis_collections().order_by('name') collections_dict = OrderedDict() for collection in collections: collections_dict[collection.id] = { 'collection': collection, 'thesis_count': Thesis.objects.filter(collection=collection).count(), 'recent_theses': list( Thesis.objects.filter(collection=collection) .order_by('-publication_year', '-oai_datestamp')[:3]) } context['collections_dict'] = collections_dict return context
def get_context_data(self, **kwargs): context = super(ThesisHomeView, self).get_context_data(**kwargs) # Fetches the collections associated with theses. collections = get_thesis_collections().order_by('name') collections_dict = OrderedDict() for collection in collections: collections_dict[collection.id] = { 'collection': collection, 'thesis_count': Thesis.objects.filter(collection=collection).count(), 'recent_theses': list( Thesis.objects.filter(collection=collection).order_by( '-publication_year', '-oai_datestamp')[:3]) } context['collections_dict'] = collections_dict return context
def get_queryset(self): return get_thesis_collections()