diff --git a/demo/demoproject/download/views.py b/demo/demoproject/download/views.py index a073aa6..c31d293 100644 --- a/demo/demoproject/download/views.py +++ b/demo/demoproject/download/views.py @@ -12,27 +12,26 @@ from demoproject.download.models import Document # Some initializations. +#: Directory containing code of :py:module:`demoproject.download.views`. app_dir = dirname(abspath(__file__)) -"""Directory containing code of :py:module:`demoproject.download.views`.""" +#: Directory containing files fixtures. fixtures_dir = join(app_dir, 'fixtures') -"""Directory containing files fixtures.""" +#: Path to a text file that says 'Hello world!'. hello_world_path = join(fixtures_dir, 'hello-world.txt') -"""Path to a text file that says 'Hello world!'.""" +#: Storage for fixtures. fixtures_storage = FileSystemStorage(location=fixtures_dir) -"""Storage for fixtures.""" # Here are the views. + +#: Direct download of one file, based on an absolute path. +#: +#: You could use this example as a shortcut, inside other views. download_hello_world = PathDownloadView.as_view(path=hello_world_path) -"""Direct download of one file, based on an absolute path. - -You could use this example as a shortcut, inside other views. - -""" class CustomPathDownloadView(PathDownloadView): @@ -52,14 +51,14 @@ class CustomPathDownloadView(PathDownloadView): path = super(CustomPathDownloadView, self).get_path() return join(fixtures_dir, path) +#: Pre-configured :py:class:`CustomPathDownloadView`. download_fixture_from_path = CustomPathDownloadView.as_view() -"""Pre-configured :py:class:`CustomPathDownloadView`.""" +#: Pre-configured view using a storage. download_fixture_from_storage = StorageDownloadView.as_view( storage=fixtures_storage) -"""Pre-configured view using a storage.""" +#: Pre-configured download view for :py:class:`Document` model. download_document = ObjectDownloadView.as_view(model=Document) -"""Pre-configured download view for :py:class:`Document` model.""" diff --git a/django_downloadview/views.py b/django_downloadview/views.py index 4fb3428..60a0275 100644 --- a/django_downloadview/views.py +++ b/django_downloadview/views.py @@ -70,16 +70,14 @@ class BaseDownloadView(DownloadMixin, View): class PathDownloadView(BaseDownloadView): """Serve a file using filename.""" + #: Server-side name (including path) of the file to serve. + #: + #: Filename is supposed to be an absolute filename of a file located on the + #: local filesystem. path = None - """Server-side name (including path) of the file to serve. - - Filename is supposed to be an absolute filename of a file located on the - local filesystem. - - """ + #: Name of the URL argument that contains path. path_url_kwarg = 'path' - """Name of the URL argument that contains path.""" def get_path(self): """Return actual path of the file to serve. @@ -100,11 +98,11 @@ class PathDownloadView(BaseDownloadView): class StorageDownloadView(PathDownloadView): """Serve a file using storage and filename.""" + #: Storage the file to serve belongs to. storage = DefaultStorage() - """Storage the file to serve belongs to.""" + #: Path to the file to serve relative to storage. path = None # Override docstring. - """Path to the file to serve relative to storage.""" def get_path(self): """Return path of the file to serve, relative to storage.