Exemple #1
0
    def get(self, request, *args, **kwargs):
        review = self.get_object()

        if not review.comments:
            raise Http404('This review has no comments')

        return serve_model_file_field(review, 'comments')
Exemple #2
0
    def test_serve_file_field(self):
        self.rev.pdf_file = self.sample_pdf
        self.rev.save()

        res = serve_model_file_field(self.rev, 'pdf_file')
        self.assertTrue(isinstance(res, HttpResponse))
        self.assertTrue('X-Accel-Redirect' in res)
Exemple #3
0
    def get(self, request, *args, **kwargs):
        """Get a single MetadataRevision FileField instance."""

        doc_or_revision = self.get_object()
        field_name = self.kwargs.get('field_name')
        return serve_model_file_field(doc_or_revision, field_name)
Exemple #4
0
 def test_serve_empty_field(self):
     with self.assertRaises(Http404):
         serve_model_file_field(self.rev, 'pdf_file')
Exemple #5
0
 def test_serve_wrong_field(self):
     with self.assertRaises(Http404):
         serve_model_file_field(self.rev, 'i_do_not_exist')