Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Django Private Storage
Commits
faff7384
Commit
faff7384
authored
Oct 06, 2016
by
Diederik van der Boor
Browse files
Update README WITH PRIVATE_STORAGE_AUTH_FUNCTION
parent
78b27e0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
README.rst
View file @
faff7384
...
@@ -43,7 +43,7 @@ In a Django model, add the ``PrivateFileField``:
...
@@ -43,7 +43,7 @@ In a Django model, add the ``PrivateFileField``:
class MyModel(models.Model):
class MyModel(models.Model):
title = models.CharField("Title", max_length=200)
title = models.CharField("Title", max_length=200)
file = PrivateFileField("Title")
file = PrivateFileField("Title"
, upload_to="mymodel"
)
The ``PrivateFileField`` also accepts the following kwargs:
The ``PrivateFileField`` also accepts the following kwargs:
...
@@ -61,6 +61,13 @@ Defining access rules
...
@@ -61,6 +61,13 @@ Defining access rules
The ``PRIVATE_STORAGE_AUTH_FUNCTION`` defines which user may access the files.
The ``PRIVATE_STORAGE_AUTH_FUNCTION`` defines which user may access the files.
By default, this only includes superusers.
By default, this only includes superusers.
The following options are available out of the box:
* ``private_storage.permissions.allow_authenticated``
* ``private_storage.permissions.allow_staff``
* ``private_storage.permissions.allow_superuser``
You can create a custom function, and use that instead.
The function receives a ``private_storate.models.PrivateFile`` object,
The function receives a ``private_storate.models.PrivateFile`` object,
which has the following fields:
which has the following fields:
...
...
private_storage/appconfig.py
View file @
faff7384
...
@@ -2,7 +2,7 @@ from django.conf import settings
...
@@ -2,7 +2,7 @@ from django.conf import settings
PRIVATE_STORAGE_ROOT
=
getattr
(
settings
,
'PRIVATE_STORAGE_ROOT'
,
None
)
PRIVATE_STORAGE_ROOT
=
getattr
(
settings
,
'PRIVATE_STORAGE_ROOT'
,
None
)
PRIVATE_STORAGE_SERVER
=
getattr
(
settings
,
'PRIVATE_STORAGE_SERVER'
,
'django'
)
PRIVATE_STORAGE_SERVER
=
getattr
(
settings
,
'PRIVATE_STORAGE_SERVER'
,
'django'
)
PRIVATE_STORAGE_AUTH_FUNCTION
=
getattr
(
settings
,
'PRIVATE_STORAGE_AUTH_FUNCTION'
,
'
apps.utils.
private_storage.permissions.allow_superuser'
)
PRIVATE_STORAGE_AUTH_FUNCTION
=
getattr
(
settings
,
'PRIVATE_STORAGE_AUTH_FUNCTION'
,
'private_storage.permissions.allow_superuser'
)
# For Nginx X-Accel-Redirect
# For Nginx X-Accel-Redirect
PRIVATE_STORAGE_INTERNAL_URL
=
getattr
(
settings
,
'PRIVATE_STORAGE_INTERNAL_URL'
,
'/private-x-accel-redirect/'
)
PRIVATE_STORAGE_INTERNAL_URL
=
getattr
(
settings
,
'PRIVATE_STORAGE_INTERNAL_URL'
,
'/private-x-accel-redirect/'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment