Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit 09c176a

Browse files
author
Samuel Walladge
committed
use same user path function for upload and browse
- fixes issue django-ckeditor#410 where browsing images broken while using a custom upload prefix
1 parent 60b702a commit 09c176a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

ckeditor_uploader/views.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from ckeditor_uploader.forms import SearchForm
1919

2020

21-
def get_upload_filename(upload_name, user):
21+
def _get_user_path(user):
2222
user_path = ''
2323

2424
# If CKEDITOR_RESTRICT_BY_USER is True upload file to user specific path.
@@ -34,6 +34,13 @@ def get_upload_filename(upload_name, user):
3434
else:
3535
user_path = user_prop
3636

37+
return user_path
38+
39+
40+
def get_upload_filename(upload_name, user):
41+
42+
user_path = _get_user_path(user)
43+
3744
# Generate date based path to put uploaded file.
3845
# If CKEDITOR_RESTRICT_BY_DATE is True upload file to date specific path.
3946
if getattr(settings, 'CKEDITOR_RESTRICT_BY_DATE', True):
@@ -145,9 +152,10 @@ def get_image_files(user=None, path=''):
145152
STORAGE_DIRECTORIES = 0
146153
STORAGE_FILES = 1
147154

148-
restrict = getattr(settings, 'CKEDITOR_RESTRICT_BY_USER', False)
149-
if user and not user.is_superuser and restrict:
150-
user_path = user.get_username()
155+
# allow browsing from anywhere if user is superuser
156+
# otherwise use the user path
157+
if user and not user.is_superuser:
158+
user_path = _get_user_path(user)
151159
else:
152160
user_path = ''
153161

0 commit comments

Comments
 (0)