Exemplo n.º 1
0
 def test_can_determine_the_thesis_counts_per_publication_year(self):
     # Setup
     author = AuthorFactory.create()
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection, author=author,
         publication_year=2010)
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2', collection=collection, author=author,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3', collection=collection, author=author,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(  # noqa
         localidentifier='thesis-4', collection=collection, author=author,
         publication_year=2014)
     thesis_5 = ThesisFactory.create(  # noqa
         localidentifier='thesis-5', collection=collection, author=author,
         publication_year=2012)
     thesis_6 = ThesisFactory.create(  # noqa
         localidentifier='thesis-6', collection=collection, author=author,
         publication_year=2012)
     thesis_7 = ThesisFactory.create(  # noqa
         localidentifier='thesis-7', collection=collection, author=author,
         publication_year=2014)
     # Run
     aggs = get_thesis_counts_per_publication_year(Thesis.objects.all())
     # Check
     assert aggs[0] == {'publication_year': 2014, 'total': 2}
     assert aggs[1] == {'publication_year': 2013, 'total': 1}
     assert aggs[2] == {'publication_year': 2012, 'total': 3}
     assert aggs[3] == {'publication_year': 2010, 'total': 1}
Exemplo n.º 2
0
 def get_context_data(self, **kwargs):
     context = super(ThesisPublicationYearListView,
                     self).get_context_data(**kwargs)
     context['publication_year'] = int(self.kwargs.get(self.year_url_kwarg))
     context[
         'other_publication_years'] = get_thesis_counts_per_publication_year(
             Thesis.objects.filter(collection=self.collection))
     return context
Exemplo 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
     }
Exemplo n.º 4
0
 def test_can_determine_the_thesis_counts_per_publication_year(self):
     # Setup
     author = AuthorFactory.create()
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1',
         collection=collection,
         author=author,
         publication_year=2010)
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2',
         collection=collection,
         author=author,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3',
         collection=collection,
         author=author,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(  # noqa
         localidentifier='thesis-4',
         collection=collection,
         author=author,
         publication_year=2014)
     thesis_5 = ThesisFactory.create(  # noqa
         localidentifier='thesis-5',
         collection=collection,
         author=author,
         publication_year=2012)
     thesis_6 = ThesisFactory.create(  # noqa
         localidentifier='thesis-6',
         collection=collection,
         author=author,
         publication_year=2012)
     thesis_7 = ThesisFactory.create(  # noqa
         localidentifier='thesis-7',
         collection=collection,
         author=author,
         publication_year=2014)
     # Run
     aggs = get_thesis_counts_per_publication_year(Thesis.objects.all())
     # Check
     assert aggs[0] == {'publication_year': 2014, 'total': 2}
     assert aggs[1] == {'publication_year': 2013, 'total': 1}
     assert aggs[2] == {'publication_year': 2012, 'total': 3}
     assert aggs[3] == {'publication_year': 2010, 'total': 1}
Exemplo 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}
Exemplo n.º 6
0
 def get_context_data(self, **kwargs):
     context = super(ThesisPublicationYearListView, self).get_context_data(**kwargs)
     context['publication_year'] = int(self.kwargs.get(self.year_url_kwarg))
     context['other_publication_years'] = get_thesis_counts_per_publication_year(
         Thesis.objects.filter(collection=self.collection))
     return context