Skip to content

Commit

Permalink
Renamed public/private to disabled/enabled permission checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitar committed Apr 30, 2011
1 parent b50ac3d commit 1dcc177
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 55 deletions.
17 changes: 9 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ Add ``"filer"`` to your project's ``INSTALLED_APPS`` setting and run ``syncdb``
Configuration
-------------

django-filer can handle public and private files. Public files are your regular
world readable files in ``MEDIA_ROOT``. Private files are a other case however.
To be able to check permissions on the file downloads a special view is used and
they are saved in a separate location (in a directory called `smedia` next to
django-filer supports permissions on files. They can be enabled or disabled.
Files with disabled permissions are your regular world readable files in
``MEDIA_ROOT``. Files with permissions are a other case however. To be able to
check permissions on the file downloads a special view is used and they are
saved in a separate location (in a directory called `smedia` next to
``MEDIA_ROOT`` by default).

``filer.server.urls`` needs to be included in the root ``urls.py``::
Expand All @@ -43,9 +44,9 @@ they are saved in a separate location (in a directory called `smedia` next to
url(r'^', include('filer.server.urls')),
)

By default private files are served directly by django. That is acceptable in
a development environment, but very bad for performance in production. See
the docs on how to serve files more efficiently.
By default files with permissions are served directly by django. That is
acceptable in a development environment, but very bad for performance in
production. See the docs on how to serve files more efficiently.


For automatic subject location aware cropping of images replace
Expand All @@ -65,4 +66,4 @@ For automatic subject location aware cropping of images replace
.. _easy_thumbnails: https://github.com/SmileyChris/easy-thumbnails
.. _sorl.thumbnail: http://thumbnail.sorl.net/
.. _PIL: http://www.pythonware.com/products/pil/
.. _Pillow: http://pypi.python.org/pypi/Pillow/
.. _Pillow: http://pypi.python.org/pypi/Pillow/
24 changes: 13 additions & 11 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ Make sure that they are accessible at one of those locations.
See the :ref:`FILER_STATICMEDIA_PREFIX` setting if you want to serve them from
somewhere else.

private files
.............

django-filer can handle public and private files. Public files are your regular
world readable files in ``MEDIA_ROOT``. Private files are a other case however.
To be able to check permissions on the file downloads, a special view is used and
they are saved in a separate location (in a directory called ``smedia`` next to
permissions on files
....................

django-filer supports permissions on files. They can be enabled or disabled.
Files with disabled permissions are your regular world readable files in
``MEDIA_ROOT``. Files with permissions are a other case however. To be able to
check permissions on the file downloads a special view is used and they are
saved in a separate location (in a directory called `smedia` next to
``MEDIA_ROOT`` by default).

``filer.server.urls`` needs to be included in the root ``urls.py``::
Expand All @@ -66,9 +67,10 @@ they are saved in a separate location (in a directory called ``smedia`` next to
url(r'^', include('filer.server.urls')),
)

By default private files are served directly by `django`_. That is acceptable in
a development environment, but very bad for performance in production. See
the docs on :ref:`how to serve files more efficiently <server>`.
By default files with permissions are served directly by `django`_. That is
acceptable in a development environment, but very bad for performance in
production. See the docs on :ref:`how to serve files more efficiently
<server>`.

subject location aware cropping
...............................
Expand Down Expand Up @@ -109,4 +111,4 @@ To crop an image and respect the subject location::
.. _django-mptt: https://github.com/django-mptt/django-mptt/
.. _Pillow: http://pypi.python.org/pypi/Pillow/
.. _pip: http://pypi.python.org/pypi/pip
.. _South: http://south.aeracode.org/
.. _South: http://south.aeracode.org/
24 changes: 12 additions & 12 deletions docs/server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
Server
======

django-filer can handle public and private files. Public files are your regular
world readable files in ``MEDIA_ROOT``. Private files are a other case however.
To be able to check permissions on the file downloads a special view is used and
they are saved in a separate location. The default is a directory called
``smedia`` next to ``MEDIA_ROOT`` that must *NOT* be served by the webserver
directly.
django-filer supports permissions on files. They can be enabled or disabled.
Files with disabled permissions are your regular world readable files in
``MEDIA_ROOT``. Files with permissions are a other case however. To be able to
check permissions on the file downloads a special view is used and they are
saved in a separate location. The default is a directory called ``smedia`` next
to ``MEDIA_ROOT`` that must *NOT* be served by the webserver directly.

``filer.server.urls`` needs to be included in the root ``urls.py``::

urlpatterns += patterns('',
url(r'^', include('filer.server.urls')),
)

The view will serve the private media files by delegating to one of its server
backends. The ones bundled with django-filer live in ``filer.server.backends``
and it is easy to create new ones.
The view will serve the permission-checked media files by delegating to one of
its server backends. The ones bundled with django-filer live in
``filer.server.backends`` and it is easy to create new ones.

The default is ``filer.server.backends.default.DefaultServer``. It is suitable
for development and serves the file directly from django.
Expand Down Expand Up @@ -49,9 +49,9 @@ in ``settings.py``::
location=FILER_PRIVATEMEDIA_THUMBNAIL_ROOT,
nginx_location='/nginx_filer_private_thumbnails')

``nginx_location`` is the location directive where nginx "hides" private files
from general access. A fitting nginx configuration might look something like
this::
``nginx_location`` is the location directive where nginx "hides"
permission-checked files from general access. A fitting nginx configuration
might look something like this::
location /nginx_filer_private/ {
internal;
Expand Down
34 changes: 18 additions & 16 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Settings
``FILER_IS_PUBLIC_DEFAULT``
---------------------------

Should newly uploaded files be private or public by default.
Should newly uploaded files have permission checking disabled (be public) by default.

Defaults to `False` (new files are private)
Defaults to `False` (new files have permission checking enabled, are private)

.. _FILER_STATICMEDIA_PREFIX:

Expand All @@ -27,18 +27,18 @@ directory should be served.
-----------------------

``FILER_PUBLICMEDIA_ROOT``
The base directory for public media.
The base directory for public (without permission checks) media.

Defaults to ``<MEDIA_ROOT>/filer/``

``FILER_PUBLICMEDIA_URL``
The url prefix for public media.
The url prefix for public (without permission checks) media.

Defaults to ``<MEDIA_URL>/filer/``

``FILER_PUBLICMEDIA_STORAGE``
The storage backend for public files. Must be an instance of a storage
class.
The storage backend for public (without permission checks) files. Must be
an instance of a storage class.

Defaults to ``filer.storage.PublicFileSystemStorage`` using
``FILER_PUBLICMEDIA_ROOT`` and ``FILER_PUBLICMEDIA_URL`` as ``location`` and
Expand All @@ -48,7 +48,8 @@ directory should be served.
The function to generate the path relative to the storage root. The
default generates a date based path like ``2011/05/03/filename.jpg``. This
will be applied with the current date whenever a file is uploaded or moved
between public and private storages.
between public (without permission checks) and private (with permission
checks) storages.

Defaults to ``'filer.utils.generate_filename.by_date'``

Expand All @@ -73,18 +74,18 @@ directory should be served.
------------------------

``FILER_PRIVATEMEDIA_ROOT``
The base directory for private media.
The base directory for private (with permission checks) media.

Defaults to ``<MEDIA_ROOT>/../smedia/filer/``

``FILER_PRIVATEMEDIA_URL``
The url prefix for private media.
The url prefix for private (with permission checks) media.

Defaults to ``/smedia/filer/``

``FILER_PRIVATEMEDIA_STORAGE``
The storage backend for private files. Must be an instance of a storage
class.
The storage backend for private (with permission checks) files. Must be
an instance of a storage class.

Defaults to ``filer.storage.PublicFileSystemStorage`` using
``FILER_PRIVATEMEDIA_ROOT`` and ``FILER_PRIVATEMEDIA_URL`` as ``location`` and
Expand All @@ -94,7 +95,8 @@ directory should be served.
The function to generate the path relative to the storage root. The
default generates a date based path like ``2011/05/03/filename.jpg``. This
will be applied with the current date whenever a file is uploaded or moved
between public and private storages.
between public (without permission checks) and private (with permission
checks) storages.

Defaults to ``'filer.utils.generate_filename.by_date'``

Expand All @@ -116,10 +118,10 @@ directory should be served.
as ``location`` and ``base_url``.

``FILER_PRIVATEMEDIA_SERVER``
The server backend to use to serve the private files with. The default
serves the file entirely with django. This is not what you want on a
production server. Use one of the other server backends in production
instead:
The server backend to use to serve the private (with permission checks)
files with. The default serves the file entirely with django. This is not
what you want on a production server. Use one of the other server backends
in production instead:

* ``filer.server.backends.nginx.NginxXAccelRedirectServer``
* ``filer.server.backends.xsendfile.ApacheXSendfileServer``
Expand Down
2 changes: 1 addition & 1 deletion filer/models/filemodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class File(models.Model, mixins.IconsMixin):
uploaded_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True)

is_public = models.BooleanField(default=False)
is_public = models.BooleanField(default=False, verbose_name=_('Permissions disabled'), help_text=_('Disable any permission checking for this file. File will be publicly accessible to anyone.'))

objects = FileManager()

Expand Down
4 changes: 2 additions & 2 deletions filer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'16', '32', '48', '64',
)

# Public Media
# Public media (media accessible without any permission checks)

FILER_PUBLICMEDIA_ROOT = getattr(settings, 'FILER_PUBLICMEDIA_ROOT',
os.path.abspath( os.path.join(settings.MEDIA_ROOT, 'filer' ) ) )
Expand All @@ -45,7 +45,7 @@
base_url=FILER_PUBLICMEDIA_THUMBNAIL_URL
))

# Private Media
# Private media (media accessible through permissions checks)

FILER_PRIVATEMEDIA_ROOT = getattr(settings, 'FILER_PRIVATEMEDIA_ROOT',
os.path.abspath( os.path.join(settings.MEDIA_ROOT, '../smedia/filer/' ) ) )
Expand Down
10 changes: 5 additions & 5 deletions filer/templates/admin/filer/folder/directory_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<!-- Directory details -->
<td>
<a style="display: block; float: right;" class="changelink" href="{{ subfolder.get_admin_url_path }}{% if is_popup %}?_popup=1{% if select_folder %}&select_folder=1{% endif %}{% endif %}" title="{% blocktrans with subfolder.name as item_label %}Change '{{ item_label }}' folder details{% endblocktrans %}">{% trans "Change" %}</a>
<div><b><a href="{{ subfolder.get_admin_directory_listing_url_path }}{% if is_popup %}?_popup=1{% if select_folder %}&select_folder=1{% endif %}{% endif %}" title="{% blocktrans with subfolder.name as item_label %}Change '{{ item_label }}' folder details{% endblocktrans %}">{{ subfolder.name }}</a></b></div>
<div>{% trans "Owner" %}: {{ subfolder.owner|default:"n/a" }} {% trans "Folders" %}: {{ subfolder.children_count|default:"0" }} {% trans "Files" %}: {{ subfolder.file_count|default:"0" }}</div>
<div><b><a href="{{ subfolder.get_admin_directory_listing_url_path }}{% if is_popup %}?_popup=1{% if select_folder %}&select_folder=1{% endif %}{% endif %}" title="{% blocktrans with subfolder.name as item_label %}Change '{{ item_label }}' folder details{% endblocktrans %}">{{ subfolder.name }}</a></b>{% if not subfolder.is_root %}<span class="tiny"> ({% blocktrans count subfolder.children_count|default:"0" as counter %}1 folder{% plural %}{{ counter }} folders{% endblocktrans %}, {% blocktrans count subfolder.file_count|default:"0" as counter %}1 file{% plural %}{{ counter }} files{% endblocktrans %})</span>{% endif %}</div>
<div>{% trans "Owner" %}: {{ subfolder.owner|default:"n/a" }}</div>
</td>
<td></td>
</tr>
Expand All @@ -36,9 +36,9 @@
<!-- Filename/Dimensions -->
<td>
<a style="display: block; float: right;" class="changelink" href="{{ file.get_admin_url_path }}{% if is_popup %}?_popup=1{% endif %}" title="{% blocktrans with file.label as item_label %}Change '{{ item_label }}' details{% endblocktrans %}">{% trans "Change" %}</a>
<div><b><a href="{{ file.get_admin_url_path }}{% if is_popup %}?_popup=1{% endif %}" title="{% blocktrans with file.label as item_label %}Change '{{ item_label }}' details{% endblocktrans %}">{{ file.label }}</a></b><span class="tiny"> ({{ file.size|filesize:"auto1000long" }})</span></div>
{% ifequal file.file_type "Image" %}<div>{{ file.width }} x {{ file.height }} px </div>{% endifequal %}
{% if file.owner %}<div>{% trans "Owner" %}: {{ file.owner }}</div>{% endif %}
<div><b><a href="{{ file.get_admin_url_path }}{% if is_popup %}?_popup=1{% endif %}" title="{% blocktrans with file.label as item_label %}Change '{{ item_label }}' details{% endblocktrans %}">{{ file.label }}</a></b><span class="tiny"> ({{ file.size|filesize:"auto1000long" }}{% ifequal file.file_type "Image" %}, {{ file.width }}x{{ file.height }} px{% endifequal %})</span></div>
<div>{% trans "Owner" %}: {{ file.owner|default:"n/a" }}</div>
<div>{% trans "Permissions" %}: {% if file.is_public %}{% trans "disabled" %}{% else %}{% trans "enabled" %}{% endif %}</div>
{# {% if file.has_all_mandatory_data %}<div><img alt="0" src="{{ ADMIN_MEDIA_PREFIX }}admin/img/admin/icon-yes.gif" /> {% trans "has all mandatory metadata" %}</div>{% else %}<div><img alt="1" src="{{ ADMIN_MEDIA_PREFIX }}img/admin/icon-no.gif"/> {% trans "missing metadata!" %}</div>{% endif %} #}
</td>
<td style="text-align: right;">
Expand Down

0 comments on commit 1dcc177

Please sign in to comment.