Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-wiki
Commits
6b9f346c
Commit
6b9f346c
authored
Jan 16, 2013
by
benjaoming
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #92 from gluwa/master
Added custom storage backend to the images plugin
parents
64a22a81
55a4a5b2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
2 deletions
+9
-2
wiki/plugins/attachments/models.py
+4
-1
wiki/plugins/images/models.py
+2
-1
wiki/plugins/images/settings.py
+3
-0
No files found.
wiki/plugins/attachments/models.py
View file @
6b9f346c
...
...
@@ -73,7 +73,10 @@ def upload_path(instance, filename):
import
random
,
hashlib
m
=
hashlib
.
md5
(
str
(
random
.
randint
(
0
,
100000000000000
)))
upload_path
=
path
.
join
(
upload_path
,
m
.
hexdigest
())
return
path
.
join
(
upload_path
,
filename
+
'.upload'
)
if
settings
.
APPEND_EXTENSION
:
filename
+=
'.upload'
return
path
.
join
(
upload_path
,
filename
)
class
AttachmentRevision
(
BaseRevisionMixin
,
models
.
Model
):
...
...
wiki/plugins/images/models.py
View file @
6b9f346c
...
...
@@ -52,7 +52,8 @@ class ImageRevision(RevisionPluginRevision):
image
=
models
.
ImageField
(
upload_to
=
upload_path
,
max_length
=
2000
,
height_field
=
'height'
,
width_field
=
'width'
,
blank
=
True
,
null
=
True
)
width_field
=
'width'
,
blank
=
True
,
null
=
True
,
storage
=
settings
.
STORAGE_BACKEND
)
width
=
models
.
SmallIntegerField
(
blank
=
True
,
null
=
True
)
height
=
models
.
SmallIntegerField
(
blank
=
True
,
null
=
True
)
...
...
wiki/plugins/images/settings.py
View file @
6b9f346c
...
...
@@ -3,6 +3,9 @@ from django.conf import settings as django_settings
# Where to store images
IMAGE_PATH
=
getattr
(
django_settings
,
'WIKI_IMAGE_PATH'
,
"wiki/images/
%
aid/"
)
from
django.core.files.storage
import
default_storage
STORAGE_BACKEND
=
getattr
(
django_settings
,
'WIKI_STORAGE_BACKEND'
,
default_storage
)
# Should the upload path be obscurified? If so, a random hash will be added to the path
# such that someone can not guess the location of files (if you have
# restricted permissions and the files are still located within the web server's
...
...
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