Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
5d903669
Commit
5d903669
authored
Aug 23, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed file uploading
parent
0b00e3b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
+15
-5
lms/djangoapps/django_comment_client/base/views.py
+5
-5
lms/djangoapps/django_comment_client/settings.py
+10
-0
No files found.
lms/djangoapps/django_comment_client/base/views.py
View file @
5d903669
...
...
@@ -21,7 +21,6 @@ from django.contrib.auth.models import User
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
courseware.courses
import
get_course_with_access
from
django_comment_client.utils
import
JsonResponse
,
JsonError
,
extract
from
django_comment_client.permissions
import
check_permissions_by_view
...
...
@@ -337,8 +336,8 @@ def upload(request, course_id):#ajax upload file to a question or answer
# check file type
f
=
request
.
FILES
[
'file-upload'
]
file_extension
=
os
.
path
.
splitext
(
f
.
name
)[
1
]
.
lower
()
if
not
file_extension
in
settings
.
DISCUSSION_
ALLOWED_UPLOAD_FILE_TYPES
:
file_types
=
"', '"
.
join
(
settings
.
DISCUSSION_
ALLOWED_UPLOAD_FILE_TYPES
)
if
not
file_extension
in
cc_settings
.
ALLOWED_UPLOAD_FILE_TYPES
:
file_types
=
"', '"
.
join
(
cc_settings
.
ALLOWED_UPLOAD_FILE_TYPES
)
msg
=
_
(
"allowed file types are '
%(file_types)
s'"
)
%
\
{
'file_types'
:
file_types
}
raise
exceptions
.
PermissionDenied
(
msg
)
...
...
@@ -357,15 +356,16 @@ def upload(request, course_id):#ajax upload file to a question or answer
# check file size
# byte
size
=
file_storage
.
size
(
new_file_name
)
if
size
>
settings
.
ASKBOT_
MAX_UPLOAD_FILE_SIZE
:
if
size
>
cc_settings
.
MAX_UPLOAD_FILE_SIZE
:
file_storage
.
delete
(
new_file_name
)
msg
=
_
(
"maximum upload file size is
%(file_size)
sK"
)
%
\
{
'file_size'
:
settings
.
ASKBOT_
MAX_UPLOAD_FILE_SIZE
}
{
'file_size'
:
cc_settings
.
MAX_UPLOAD_FILE_SIZE
}
raise
exceptions
.
PermissionDenied
(
msg
)
except
exceptions
.
PermissionDenied
,
e
:
error
=
unicode
(
e
)
except
Exception
,
e
:
print
e
logging
.
critical
(
unicode
(
e
))
error
=
_
(
'Error uploading file. Please contact the site administrator. Thank you.'
)
...
...
lms/djangoapps/django_comment_client/settings.py
0 → 100644
View file @
5d903669
from
django.conf
import
settings
MAX_COMMENT_DEPTH
=
None
MAX_UPLOAD_FILE_SIZE
=
1024
*
1024
#result in bytes
ALLOWED_UPLOAD_FILE_TYPES
=
(
'.jpg'
,
'.jpeg'
,
'.gif'
,
'.bmp'
,
'.png'
,
'.tiff'
)
if
hasattr
(
settings
,
'DISCUSSION_SETTINGS'
):
MAX_COMMENT_DEPTH
=
settings
.
DISCUSSION_SETTINGS
.
get
(
'MAX_COMMENT_DEPTH'
)
MAX_UPLOAD_FILE_SIZE
=
settings
.
DISCUSSION_SETTINGS
.
get
(
'MAX_UPLOAD_FILE_SIZE'
)
or
MAX_UPLOAD_FILE_SIZE
ALLOWED_UPLOAD_FILE_TYPES
=
settings
.
DISCUSSION_SETTINGS
.
get
(
'ALLOWED_UPLOAD_FILE_TYPES'
)
or
ALLOWED_UPLOAD_FILE_TYPES
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