diff options
| author | Vajrasky Kok <sky.kok@speaklikeaking.com> | 2013-10-19 20:40:12 +0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-10-24 17:40:01 -0400 |
| commit | 9eecb9169566db263e243e4522b08ea1403ee95f (patch) | |
| tree | 0da80e779e7702ff2ba05f9c9d6f0ff5b15edb03 /django/core | |
| parent | c052699be3637c22e3a26383a4bdabc8c3cc0feb (diff) | |
Fixed #21219 -- Added a way to set different permission for static files.
Previously, when collecting static files, the files would receive permission
from FILE_UPLOAD_PERMISSIONS. Now, there's an option to give different
permission from uploaded files permission by subclassing any of the static
files storage classes and setting the file_permissions_mode parameter.
Thanks dblack at atlassian.com for the suggestion.
Diffstat (limited to 'django/core')
| -rw-r--r-- | django/core/files/storage.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/django/core/files/storage.py b/django/core/files/storage.py index b42981cb5e..b05f3647c0 100644 --- a/django/core/files/storage.py +++ b/django/core/files/storage.py @@ -147,7 +147,7 @@ class FileSystemStorage(Storage): Standard filesystem storage """ - def __init__(self, location=None, base_url=None): + def __init__(self, location=None, base_url=None, file_permissions_mode=None): if location is None: location = settings.MEDIA_ROOT self.base_location = location @@ -155,6 +155,10 @@ class FileSystemStorage(Storage): if base_url is None: base_url = settings.MEDIA_URL self.base_url = base_url + self.file_permissions_mode = ( + file_permissions_mode if file_permissions_mode is not None + else settings.FILE_UPLOAD_PERMISSIONS + ) def _open(self, name, mode='rb'): return File(open(self.path(name), mode)) @@ -232,8 +236,8 @@ class FileSystemStorage(Storage): # OK, the file save worked. Break out of the loop. break - if settings.FILE_UPLOAD_PERMISSIONS is not None: - os.chmod(full_path, settings.FILE_UPLOAD_PERMISSIONS) + if self.file_permissions_mode is not None: + os.chmod(full_path, self.file_permissions_mode) return name |
