Exemplo n.º 1
0
    def test_save_as(self):
        server = DefaultServer()
        request = Mock()
        request.META = {}
        response = server.serve(request, self.filer_file.file, save_as=True)
        self.assertEqual(response['Content-Disposition'], 'attachment; filename=testimage.jpg')

        response = server.serve(request, self.filer_file.file, save_as=False)
        self.assertFalse(response.has_header('Content-Disposition'))

        response = server.serve(request, self.filer_file.file, save_as='whatever.png')
        self.assertEqual(response['Content-Disposition'], 'attachment; filename=whatever.png')
Exemplo n.º 2
0
    def test_save_as(self):
        server = DefaultServer()
        request = Mock()
        request.META = {}
        response = server.serve(request, self.filer_file.file, save_as=True)
        self.assertEqual(response["Content-Disposition"], "attachment; filename=testimage.jpg")

        response = server.serve(request, self.filer_file.file, save_as=False)
        self.assertFalse(response.has_header("Content-Disposition"))

        response = server.serve(request, self.filer_file.file, save_as="whatever.png")
        self.assertEqual(response["Content-Disposition"], "attachment; filename=whatever.png")
Exemplo n.º 3
0
 def test_missing_file(self):
     server = DefaultServer()
     request = Mock()
     request.META = {}
     os.remove(self.filer_file.file.path)
     self.assertRaises(Http404, server.serve,
                       *(request, self.filer_file.file))
Exemplo n.º 4
0
 def test_not_modified(self):
     server = DefaultServer()
     request = Mock()
     request.META = {'HTTP_IF_MODIFIED_SINCE': http_date(time.time())}
     response = server.serve(request, self.filer_file)
     self.assertTrue(isinstance(response, HttpResponseNotModified))
Exemplo n.º 5
0
 def test_normal(self):
     server = DefaultServer()
     request = Mock()
     request.META = {}
     response = server.serve(request, self.filer_file)
     self.assertTrue(response.has_header('Last-Modified'))
 def test_not_modified(self):
     server = DefaultServer()
     request = Mock()
     request.META = {'HTTP_IF_MODIFIED_SINCE': http_date(time.time())}
     response = server.serve(request, self.filer_file.file)
     self.assertTrue(isinstance(response, HttpResponseNotModified))
 def test_normal(self):
     server = DefaultServer()
     request = Mock()
     request.META = {}
     response = server.serve(request, self.filer_file.file)
     self.assertTrue(response.has_header('Last-Modified'))
Exemplo n.º 8
0
    settings, 'FILER_PUBLICMEDIA_THUMBNAIL_STORAGE',
    storage_factory(klass=PublicFileSystemStorage,
                    location=os.path.abspath(
                        os.path.join(settings.MEDIA_ROOT, 'filer_thumbnails')),
                    base_url=urlparse.urljoin(settings.MEDIA_URL,
                                              'filer_thumbnails/')))

# Private media (media accessible through permissions checks)
FILER_PRIVATEMEDIA_STORAGE = getattr(
    settings, 'FILER_PRIVATEMEDIA_STORAGE',
    storage_factory(klass=PrivateFileSystemStorage,
                    location=os.path.abspath(
                        os.path.join(settings.MEDIA_ROOT, '../smedia/filer/')),
                    base_url=urlparse.urljoin(settings.MEDIA_URL,
                                              '/smedia/filer/')))
FILER_PRIVATEMEDIA_UPLOAD_TO = load_object(
    getattr(settings, 'FILER_PRIVATEMEDIA_UPLOAD_TO',
            'filer.utils.generate_filename.by_date'))
FILER_PRIVATEMEDIA_THUMBNAIL_STORAGE = getattr(
    settings, 'FILER_PRIVATEMEDIA_THUMBNAIL_STORAGE',
    storage_factory(klass=PrivateFileSystemStorage,
                    location=os.path.abspath(
                        os.path.join(settings.MEDIA_ROOT,
                                     '../smedia/filer_thumbnails/')),
                    base_url=urlparse.urljoin(settings.MEDIA_URL,
                                              '/smedia/filer_thumbnails/')))
FILER_PRIVATEMEDIA_SERVER = getattr(settings, 'FILER_PRIVATEMEDIA_SERVER',
                                    DefaultServer())
FILER_PRIVATEMEDIA_THUMBNAIL_SERVER = getattr(
    settings, 'FILER_PRIVATEMEDIA_THUMBNAIL_SERVER', DefaultServer())
Exemplo n.º 9
0
                    ))


# Private media (media accessible through permissions checks)
FILER_PRIVATEMEDIA_STORAGE = getattr(
                    settings,
                    'FILER_PRIVATEMEDIA_STORAGE',
                    storage_factory(
                        klass=PrivateFileSystemStorage,
                        location=os.path.abspath(
                            os.path.join(settings.MEDIA_ROOT,
                                         '../smedia/filer/')),
                        base_url=urlparse.urljoin(settings.MEDIA_URL,
                                                  '/smedia/filer/')
                    ))
FILER_PRIVATEMEDIA_UPLOAD_TO = load_object(getattr(settings, 'FILER_PRIVATEMEDIA_UPLOAD_TO',
                                       'filer.utils.generate_filename.by_date'))
FILER_PRIVATEMEDIA_THUMBNAIL_STORAGE = getattr(
                    settings,
                   'FILER_PRIVATEMEDIA_THUMBNAIL_STORAGE',
                    storage_factory(
                        klass=PrivateFileSystemStorage,
                        location=os.path.abspath(
                            os.path.join(settings.MEDIA_ROOT,
                                         '../smedia/filer_thumbnails/')),
                        base_url=urlparse.urljoin(settings.MEDIA_URL,
                                                  '/smedia/filer_thumbnails/')
                    ))
FILER_PRIVATEMEDIA_SERVER = getattr(settings, 'FILER_PRIVATEMEDIA_SERVER', DefaultServer())
FILER_PRIVATEMEDIA_THUMBNAIL_SERVER = getattr(settings, 'FILER_PRIVATEMEDIA_THUMBNAIL_SERVER', DefaultServer())