Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
5d903669
Commit
5d903669
authored
12 years ago
by
Rocky Duan
Browse files
Options
Downloads
Patches
Plain Diff
fixed file uploading
parent
0b00e3b0
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/django_comment_client/base/views.py
+5
-5
5 additions, 5 deletions
lms/djangoapps/django_comment_client/base/views.py
lms/djangoapps/django_comment_client/settings.py
+10
-0
10 additions, 0 deletions
lms/djangoapps/django_comment_client/settings.py
with
15 additions
and
5 deletions
lms/djangoapps/django_comment_client/base/views.py
+
5
−
5
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.
'
)
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/django_comment_client/settings.py
0 → 100644
+
10
−
0
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment