예제 #1
0
 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, ]
예제 #2
0
 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,
     ]
예제 #3
0
파일: views.py 프로젝트: erudit/eruditorg
    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
예제 #4
0
    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
예제 #5
0
 def get_queryset(self):
     return get_thesis_collections()
예제 #6
0
파일: views.py 프로젝트: erudit/eruditorg
 def get_queryset(self):
     return get_thesis_collections()