Esempio n. 1
0
 def test_can_determine_the_thesis_counts_per_author_firstletter(self):
     # Setup
     author_1 = AuthorFactory.create(lastname='Aname')
     author_2 = AuthorFactory.create(lastname='Bname')
     author_3 = AuthorFactory.create(lastname='Cname')
     author_4 = AuthorFactory.create(lastname='Dname')
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection, author=author_1,
         publication_year=2010)
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2', collection=collection, author=author_2,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3', collection=collection, author=author_3,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(  # noqa
         localidentifier='thesis-4', collection=collection, author=author_4,
         publication_year=2014)
     thesis_5 = ThesisFactory.create(  # noqa
         localidentifier='thesis-5', collection=collection, author=author_2,
         publication_year=2012)
     thesis_6 = ThesisFactory.create(  # noqa
         localidentifier='thesis-6', collection=collection, author=author_2,
         publication_year=2012)
     thesis_7 = ThesisFactory.create(  # noqa
         localidentifier='thesis-7', collection=collection, author=author_4,
         publication_year=2014)
     # Run
     aggs = get_thesis_counts_per_author_first_letter(Thesis.objects.all())
     # Check
     assert aggs[0] == {'author_firstletter': 'A', 'total': 1}
     assert aggs[1] == {'author_firstletter': 'B', 'total': 3}
     assert aggs[2] == {'author_firstletter': 'C', 'total': 1}
     assert aggs[3] == {'author_firstletter': 'D', 'total': 2}
Esempio n. 2
0
 def get_context_data(self, **kwargs):
     context = super(ThesisPublicationAuthorNameListView,
                     self).get_context_data(**kwargs)
     context['author_letter'] = self.kwargs.get(
         self.letter_url_kwarg).upper()
     context[
         'other_author_letters'] = get_thesis_counts_per_author_first_letter(
             Thesis.objects.filter(collection=self.collection))
     return context
Esempio n. 3
0
 def get_thesis_groups(self):
     collection = self.object
     theses = Thesis.objects.select_related('author').filter(
         collection=collection)
     publication_year_group = get_thesis_counts_per_publication_year(theses)
     author_name_group = get_thesis_counts_per_author_first_letter(theses)
     return {
         'by_publication_year': publication_year_group,
         'by_author_name': author_name_group
     }
Esempio n. 4
0
 def test_can_determine_the_thesis_counts_per_author_firstletter(self):
     # Setup
     author_1 = AuthorFactory.create(lastname='Aname')
     author_2 = AuthorFactory.create(lastname='Bname')
     author_3 = AuthorFactory.create(lastname='Cname')
     author_4 = AuthorFactory.create(lastname='Dname')
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1',
         collection=collection,
         author=author_1,
         publication_year=2010)
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2',
         collection=collection,
         author=author_2,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3',
         collection=collection,
         author=author_3,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(  # noqa
         localidentifier='thesis-4',
         collection=collection,
         author=author_4,
         publication_year=2014)
     thesis_5 = ThesisFactory.create(  # noqa
         localidentifier='thesis-5',
         collection=collection,
         author=author_2,
         publication_year=2012)
     thesis_6 = ThesisFactory.create(  # noqa
         localidentifier='thesis-6',
         collection=collection,
         author=author_2,
         publication_year=2012)
     thesis_7 = ThesisFactory.create(  # noqa
         localidentifier='thesis-7',
         collection=collection,
         author=author_4,
         publication_year=2014)
     # Run
     aggs = get_thesis_counts_per_author_first_letter(Thesis.objects.all())
     # Check
     assert aggs[0] == {'author_firstletter': 'A', 'total': 1}
     assert aggs[1] == {'author_firstletter': 'B', 'total': 3}
     assert aggs[2] == {'author_firstletter': 'C', 'total': 1}
     assert aggs[3] == {'author_firstletter': 'D', 'total': 2}
Esempio n. 5
0
 def get_thesis_groups(self):
     collection = self.object
     theses = Thesis.objects.select_related('author').filter(collection=collection)
     publication_year_group = get_thesis_counts_per_publication_year(theses)
     author_name_group = get_thesis_counts_per_author_first_letter(theses)
     return {'by_publication_year': publication_year_group, 'by_author_name': author_name_group}
Esempio n. 6
0
 def get_context_data(self, **kwargs):
     context = super(ThesisPublicationAuthorNameListView, self).get_context_data(**kwargs)
     context['author_letter'] = self.kwargs.get(self.letter_url_kwarg).upper()
     context['other_author_letters'] = get_thesis_counts_per_author_first_letter(
         Thesis.objects.filter(collection=self.collection))
     return context