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
80619da4
Commit
80619da4
authored
Aug 15, 2013
by
Julian Arni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Review fixes
parent
3ed41982
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
48 deletions
+47
-48
cms/djangoapps/contentstore/views/component.py
+20
-15
cms/djangoapps/contentstore/views/course.py
+27
-33
No files found.
cms/djangoapps/contentstore/views/component.py
View file @
80619da4
...
...
@@ -2,14 +2,15 @@ import json
import
logging
from
collections
import
defaultdict
from
django.http
import
HttpResponse
,
HttpResponseBadRequest
,
\
HttpResponseForbidden
from
django.http
import
(
HttpResponse
,
HttpResponseBadRequest
,
HttpResponseForbidden
)
from
django.contrib.auth.decorators
import
login_required
from
django.views.decorators.http
import
require_http_methods
from
django.core.exceptions
import
PermissionDenied
from
django_future.csrf
import
ensure_csrf_cookie
from
django.conf
import
settings
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
InvalidLocationError
from
xmodule.modulestore.exceptions
import
(
ItemNotFoundError
,
InvalidLocationError
)
from
mitxmako.shortcuts
import
render_to_response
from
xmodule.modulestore
import
Location
...
...
@@ -20,8 +21,8 @@ from xblock.core import Scope
from
util.json_request
import
expect_json
,
JsonResponse
from
contentstore.module_info_model
import
get_module_info
,
set_module_info
from
contentstore.utils
import
get_modulestore
,
get_lms_link_for_item
,
\
compute_unit_state
,
UnitState
,
get_course_for_item
from
contentstore.utils
import
(
get_modulestore
,
get_lms_link_for_item
,
compute_unit_state
,
UnitState
,
get_course_for_item
)
from
models.settings.course_grading
import
CourseGradingModel
...
...
@@ -90,7 +91,8 @@ def edit_subsection(request, location):
# we're for now assuming a single parent
if
len
(
parent_locs
)
!=
1
:
logging
.
error
(
'Multiple (or none) parents have been found for'
+
location
'Multiple (or none) parents have been found for
%
'
,
location
)
# this should blow up if we don't find any parents, which would be erroneous
...
...
@@ -209,7 +211,8 @@ def edit_unit(request, location):
pass
else
:
log
.
error
(
"Improper format for course advanced keys!"
+
course_advanced_keys
"Improper format for course advanced keys!
%
"
,
course_advanced_keys
)
components
=
[
...
...
@@ -293,11 +296,12 @@ def assignment_type_update(request, org, course, category, name):
return
HttpResponseForbidden
()
if
request
.
method
==
'GET'
:
r
eturn
JsonResponse
(
CourseGradingModel
.
get_section_grader_type
(
location
)
)
r
sp
=
CourseGradingModel
.
get_section_grader_type
(
location
)
elif
request
.
method
in
(
'POST'
,
'PUT'
):
# post or put, doesn't matter.
r
eturn
JsonResponse
(
CourseGradingModel
.
update_section_grader_type
(
r
sp
=
CourseGradingModel
.
update_section_grader_type
(
location
,
request
.
POST
))
)
return
JsonResponse
(
rsp
)
@login_required
...
...
@@ -368,7 +372,7 @@ def module_info(request, module_location):
rewrite_static_links
=
request
.
GET
.
get
(
'rewrite_url_links'
,
'True'
)
in
[
'True'
,
'true'
]
logging
.
debug
(
'rewrite_static_links = {0} {1}'
.
format
(
request
.
GET
.
get
(
'rewrite_url_links'
,
'False'
),
request
.
GET
.
get
(
'rewrite_url_links'
,
False
),
rewrite_static_links
)
)
...
...
@@ -377,13 +381,14 @@ def module_info(request, module_location):
raise
PermissionDenied
()
if
request
.
method
==
'GET'
:
r
eturn
JsonResponse
(
get_module_info
(
r
sp
=
get_module_info
(
get_modulestore
(
location
),
location
,
rewrite_static_links
=
rewrite_static_links
)
)
)
elif
request
.
method
in
(
"POST"
,
"PUT"
):
r
eturn
JsonResponse
(
set_module_info
(
r
sp
=
set_module_info
(
get_modulestore
(
location
),
location
,
request
.
POST
))
)
return
JsonResponse
(
rsp
)
cms/djangoapps/contentstore/views/course.py
View file @
80619da4
...
...
@@ -123,14 +123,14 @@ def create_new_course(request):
pass
if
existing_course
is
not
None
:
return
JsonResponse
({
'ErrMsg'
:
_
(
(
'There is already a course defined with the same '
'ErrMsg'
:
_
(
'There is already a course defined with the same '
'organization, course number, and course run. Please '
'change either organization or course number to be '
'unique.'
)
)
,
'OrgErrMsg'
:
_
(
(
'Please change either the organization or '
'course number so that it is unique.'
)
)
,
'CourseErrMsg'
:
_
(
(
'Please change either the organization or '
'course number so that it is unique.'
)
)
,
'unique.'
),
'OrgErrMsg'
:
_
(
'Please change either the organization or '
'course number so that it is unique.'
),
'CourseErrMsg'
:
_
(
'Please change either the organization or '
'course number so that it is unique.'
),
})
course_search_location
=
[
'i4x'
,
dest_location
.
org
,
dest_location
.
course
,
...
...
@@ -139,13 +139,13 @@ def create_new_course(request):
courses
=
modulestore
()
.
get_items
(
course_search_location
)
if
len
(
courses
)
>
0
:
return
JsonResponse
({
'ErrMsg'
:
_
(
(
'There is already a course defined with the same '
'ErrMsg'
:
_
(
'There is already a course defined with the same '
'organization and course number. Please '
'change at least one field to be unique.'
)
)
,
'OrgErrMsg'
:
_
(
(
'Please change either the organization or '
'course number so that it is unique.'
)
)
,
'CourseErrMsg'
:
_
(
(
'Please change either the organization or '
'course number so that it is unique.'
)
)
,
'change at least one field to be unique.'
),
'OrgErrMsg'
:
_
(
'Please change either the organization or '
'course number so that it is unique.'
),
'CourseErrMsg'
:
_
(
'Please change either the organization or '
'course number so that it is unique.'
),
})
# instantiate the CourseDescriptor and then persist it
...
...
@@ -206,9 +206,7 @@ def course_info(request, org, course, name, provided_id=None):
'context_course'
:
course_module
,
'url_base'
:
"/"
+
org
+
"/"
+
course
+
"/"
,
'course_updates'
:
json
.
dumps
(
get_course_updates
(
location
)),
'handouts_location'
:
Location
([
'i4x'
,
org
,
course
,
'course_info'
,
'handouts'
])
.
url
()
})
'handouts_location'
:
Location
([
'i4x'
,
org
,
course
,
'course_info'
,
'handouts'
])
.
url
()
})
@expect_json
...
...
@@ -227,9 +225,6 @@ def course_info_updates(request, org, course, provided_id=None):
# get current updates
location
=
[
'i4x'
,
org
,
course
,
'course_info'
,
"updates"
]
# Hmmm, provided_id is coming as empty string on create whereas I believe
# it used to be None :-( Possibly due to my removing the seemingly
# redundant pattern in urls.py
if
provided_id
==
''
:
provided_id
=
None
...
...
@@ -241,22 +236,21 @@ def course_info_updates(request, org, course, provided_id=None):
return
JsonResponse
(
get_course_updates
(
location
))
elif
request
.
method
==
'DELETE'
:
try
:
return
JsonResponse
(
delete_course_update
(
location
,
request
.
POST
,
provided_id
))
return
JsonResponse
(
delete_course_update
(
location
,
request
.
POST
,
provided_id
))
except
:
return
HttpResponseBadRequest
(
"Failed to delete"
,
content_type
=
"text/plain"
)
elif
request
.
method
in
(
'POST'
,
'PUT'
):
# can be either and sometimes
# django is rewriting one to the
# other
return
HttpResponseBadRequest
(
"Failed to delete"
,
content_type
=
"text/plain"
)
# can be either and sometimes django is rewriting one to the other:
elif
request
.
method
in
(
'POST'
,
'PUT'
):
try
:
return
JsonResponse
(
update_course_updates
(
location
,
request
.
POST
,
provided_id
))
return
JsonResponse
(
update_course_updates
(
location
,
request
.
POST
,
provided_id
))
except
:
return
HttpResponseBadRequest
(
"Failed to save"
,
content_type
=
"text/plain"
)
return
HttpResponseBadRequest
(
"Failed to save"
,
content_type
=
"text/plain"
)
@login_required
...
...
@@ -563,8 +557,8 @@ def textbook_index(request, org, course, name):
if
request
.
is_ajax
():
if
request
.
method
==
'GET'
:
return
JsonResponse
(
course_module
.
pdf_textbooks
)
elif
request
.
method
in
(
'POST'
,
'PUT'
):
# can be either and sometimes
# django is rewriting one to the other
# can be either and sometimes django is rewriting one to the other:
elif
request
.
method
in
(
'POST'
,
'PUT'
):
try
:
textbooks
=
validate_textbooks_json
(
request
.
body
)
except
TextbookValidationError
as
err
:
...
...
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