def test_get_valid_single_issue(self): response = self.client.get( reverse('api:issue-detail', kwargs={'slug': self.superman.slug})) issue = Issue.objects.get(slug=self.superman.slug) serializer = IssueSerializer(issue, context=self.serializer_context) self.assertEqual(response.data, serializer.data) self.assertEqual(response.status_code, status.HTTP_200_OK)
def recent(self, request): """ Returns the last 90 comic archives imported. """ queryset = (Issue.objects.select_related('series').prefetch_related( 'credits_set', 'credits_set__creator', 'credits_set__role').order_by('-import_date')[:90]) page = self.paginate_queryset(queryset) if page is not None: serializer = IssueSerializer(page, many=True, context={"request": request}) return self.get_paginated_response(serializer.data) else: raise Http404()
def issue_list(self, request, slug=None): """ Returns a list of issues for a series. """ series = self.get_object() queryset = ( series.issue_set .prefetch_related('credits_set', 'credits_set__creator', 'credits_set__role', 'arcs') ) page = self.paginate_queryset(queryset) if page is not None: serializer = IssueSerializer( page, many=True, context={"request": request}) return self.get_paginated_response(serializer.data) else: raise Http404()
def issue_list(self, request, slug=None): """ Returns a list of issues for a story arc. """ arc = self.get_object() # Ordering the query set by date and then series name # since the Comic Vine api doesn't appear to provide # the story arc reading order. queryset = (arc.issue_set.select_related('series').prefetch_related( 'credits_set', 'credits_set__creator', 'credits_set__role', 'arcs').order_by('date', 'series', 'number')) page = self.paginate_queryset(queryset) if page is not None: serializer = IssueSerializer(page, many=True, context={"request": request}) return self.get_paginated_response(serializer.data) else: raise Http404()