示例#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')
示例#2
0
文件: views.py 项目: Talengi/phase
    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')
示例#3
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)
示例#4
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)
示例#5
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)
示例#6
0
文件: views.py 项目: providenz/phase
    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)
示例#7
0
文件: views.py 项目: dreamyman/phase
    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)
示例#8
0
 def test_serve_empty_field(self):
     with self.assertRaises(Http404):
         serve_model_file_field(self.rev, 'pdf_file')
示例#9
0
 def test_serve_wrong_field(self):
     with self.assertRaises(Http404):
         serve_model_file_field(self.rev, 'i_do_not_exist')
示例#10
0
 def test_serve_empty_field(self):
     with self.assertRaises(Http404):
         serve_model_file_field(self.rev, 'pdf_file')
示例#11
0
 def test_serve_wrong_field(self):
     with self.assertRaises(Http404):
         serve_model_file_field(self.rev, 'i_do_not_exist')