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')
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)
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)
def get(self, request, *args, **kwargs): u"""Serve the file.""" rev = self.get_object() field_name = 'file_transmitted' return serve_model_file_field(rev, field_name)
def test_serve_empty_field(self): with self.assertRaises(Http404): serve_model_file_field(self.rev, 'pdf_file')
def test_serve_wrong_field(self): with self.assertRaises(Http404): serve_model_file_field(self.rev, 'i_do_not_exist')