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
670b595d
Commit
670b595d
authored
Feb 06, 2018
by
Diederik van der Boor
Browse files
PEP8 (except line length)
parent
495791cb
Changes
4
Hide whitespace changes
Inline
Side-by-side
makemessages.py
View file @
670b595d
...
@@ -6,13 +6,14 @@ import django
...
@@ -6,13 +6,14 @@ import django
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.management
import
call_command
from
django.core.management
import
call_command
def
main
():
def
main
():
if
not
settings
.
configured
:
if
not
settings
.
configured
:
module_root
=
path
.
dirname
(
path
.
realpath
(
__file__
))
module_root
=
path
.
dirname
(
path
.
realpath
(
__file__
))
settings
.
configure
(
settings
.
configure
(
DEBUG
=
False
,
DEBUG
=
False
,
INSTALLED_APPS
=
(
INSTALLED_APPS
=
(
'private_storage'
,
'private_storage'
,
),
),
)
)
...
@@ -20,9 +21,11 @@ def main():
...
@@ -20,9 +21,11 @@ def main():
django
.
setup
()
django
.
setup
()
makemessages
()
makemessages
()
def
makemessages
():
def
makemessages
():
os
.
chdir
(
'private_storage'
)
os
.
chdir
(
'private_storage'
)
call_command
(
'makemessages'
,
locale
=
(
'en'
,
'nl'
),
verbosity
=
1
)
call_command
(
'makemessages'
,
locale
=
(
'en'
,
'nl'
),
verbosity
=
1
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
private_storage/fields.py
View file @
670b595d
...
@@ -19,7 +19,6 @@ from django.utils.encoding import force_str, force_text
...
@@ -19,7 +19,6 @@ from django.utils.encoding import force_str, force_text
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
class
PrivateFileField
(
models
.
FileField
):
class
PrivateFileField
(
models
.
FileField
):
"""
"""
Filefield with private storage, custom filename and size checks.
Filefield with private storage, custom filename and size checks.
...
...
private_storage/storage/files.py
View file @
670b595d
...
@@ -19,6 +19,7 @@ class PrivateFileSystemStorage(FileSystemStorage):
...
@@ -19,6 +19,7 @@ class PrivateFileSystemStorage(FileSystemStorage):
Interface to the Django storage system,
Interface to the Django storage system,
storing the files in a private folder.
storing the files in a private folder.
"""
"""
def
__init__
(
self
,
location
=
None
,
base_url
=
None
,
**
kwargs
):
def
__init__
(
self
,
location
=
None
,
base_url
=
None
,
**
kwargs
):
if
location
is
None
:
if
location
is
None
:
location
=
appconfig
.
PRIVATE_STORAGE_ROOT
location
=
appconfig
.
PRIVATE_STORAGE_ROOT
...
...
runtests.py
View file @
670b595d
...
@@ -10,18 +10,18 @@ if not settings.configured:
...
@@ -10,18 +10,18 @@ if not settings.configured:
sys
.
path
.
insert
(
0
,
path
.
join
(
module_root
,
'example'
))
sys
.
path
.
insert
(
0
,
path
.
join
(
module_root
,
'example'
))
settings
.
configure
(
settings
.
configure
(
DEBUG
=
False
,
# will be False anyway by DjangoTestRunner.
DEBUG
=
False
,
# will be False anyway by DjangoTestRunner.
DATABASES
=
{
DATABASES
=
{
'default'
:
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
':memory:'
'NAME'
:
':memory:'
}
}
},
},
INSTALLED_APPS
=
(
INSTALLED_APPS
=
(
'private_storage'
,
'private_storage'
,
),
),
TEST_RUNNER
=
'django.test.runner.DiscoverRunner'
,
TEST_RUNNER
=
'django.test.runner.DiscoverRunner'
,
TEMPLATES
=
[
TEMPLATES
=
[
{
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
(),
'DIRS'
:
(),
...
@@ -49,5 +49,6 @@ def runtests():
...
@@ -49,5 +49,6 @@ def runtests():
argv
=
sys
.
argv
[:
1
]
+
[
'test'
,
'private_storage'
]
+
sys
.
argv
[
1
:]
argv
=
sys
.
argv
[:
1
]
+
[
'test'
,
'private_storage'
]
+
sys
.
argv
[
1
:]
execute_from_command_line
(
argv
)
execute_from_command_line
(
argv
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
runtests
()
runtests
()
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