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
d85f7ac9
Commit
d85f7ac9
authored
Mar 11, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1645 from MITx/feature/cdodge/pylint-cleanup
Feature/cdodge/pylint cleanup
parents
0605c941
4ec3683c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
17 deletions
+39
-17
cms/djangoapps/contentstore/tests/test_contentstore.py
+0
-1
cms/djangoapps/contentstore/views.py
+25
-3
cms/djangoapps/models/settings/course_metadata.py
+14
-13
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
d85f7ac9
...
@@ -63,7 +63,6 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
...
@@ -63,7 +63,6 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
client
=
Client
()
self
.
client
=
Client
()
self
.
client
.
login
(
username
=
uname
,
password
=
password
)
self
.
client
.
login
(
username
=
uname
,
password
=
password
)
def
check_edit_unit
(
self
,
test_course_name
):
def
check_edit_unit
(
self
,
test_course_name
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
test_course_name
])
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
test_course_name
])
...
...
cms/djangoapps/contentstore/views.py
View file @
d85f7ac9
...
@@ -86,12 +86,14 @@ def signup(request):
...
@@ -86,12 +86,14 @@ def signup(request):
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
return
render_to_response
(
'signup.html'
,
{
'csrf'
:
csrf_token
})
return
render_to_response
(
'signup.html'
,
{
'csrf'
:
csrf_token
})
def
old_login_redirect
(
request
):
def
old_login_redirect
(
request
):
'''
'''
Redirect to the active login url.
Redirect to the active login url.
'''
'''
return
redirect
(
'login'
,
permanent
=
True
)
return
redirect
(
'login'
,
permanent
=
True
)
@ssl_login_shortcut
@ssl_login_shortcut
@ensure_csrf_cookie
@ensure_csrf_cookie
def
login_page
(
request
):
def
login_page
(
request
):
...
@@ -104,6 +106,7 @@ def login_page(request):
...
@@ -104,6 +106,7 @@ def login_page(request):
'forgot_password_link'
:
"//{base}/#forgot-password-modal"
.
format
(
base
=
settings
.
LMS_BASE
),
'forgot_password_link'
:
"//{base}/#forgot-password-modal"
.
format
(
base
=
settings
.
LMS_BASE
),
})
})
def
howitworks
(
request
):
def
howitworks
(
request
):
if
request
.
user
.
is_authenticated
():
if
request
.
user
.
is_authenticated
():
return
index
(
request
)
return
index
(
request
)
...
@@ -112,6 +115,7 @@ def howitworks(request):
...
@@ -112,6 +115,7 @@ def howitworks(request):
# ==== Views for any logged-in user ==================================
# ==== Views for any logged-in user ==================================
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
def
index
(
request
):
def
index
(
request
):
...
@@ -145,6 +149,7 @@ def index(request):
...
@@ -145,6 +149,7 @@ def index(request):
# ==== Views with per-item permissions================================
# ==== Views with per-item permissions================================
def
has_access
(
user
,
location
,
role
=
STAFF_ROLE_NAME
):
def
has_access
(
user
,
location
,
role
=
STAFF_ROLE_NAME
):
'''
'''
Return True if user allowed to access this piece of data
Return True if user allowed to access this piece of data
...
@@ -393,6 +398,7 @@ def preview_component(request, location):
...
@@ -393,6 +398,7 @@ def preview_component(request, location):
'editor'
:
wrap_xmodule
(
component
.
get_html
,
component
,
'xmodule_edit.html'
)(),
'editor'
:
wrap_xmodule
(
component
.
get_html
,
component
,
'xmodule_edit.html'
)(),
})
})
@expect_json
@expect_json
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
...
@@ -720,6 +726,7 @@ def create_draft(request):
...
@@ -720,6 +726,7 @@ def create_draft(request):
return
HttpResponse
()
return
HttpResponse
()
@login_required
@login_required
@expect_json
@expect_json
def
publish_draft
(
request
):
def
publish_draft
(
request
):
...
@@ -749,6 +756,7 @@ def unpublish_unit(request):
...
@@ -749,6 +756,7 @@ def unpublish_unit(request):
return
HttpResponse
()
return
HttpResponse
()
@login_required
@login_required
@expect_json
@expect_json
def
clone_item
(
request
):
def
clone_item
(
request
):
...
@@ -779,8 +787,7 @@ def clone_item(request):
...
@@ -779,8 +787,7 @@ def clone_item(request):
return
HttpResponse
(
json
.
dumps
({
'id'
:
dest_location
.
url
()}))
return
HttpResponse
(
json
.
dumps
({
'id'
:
dest_location
.
url
()}))
#@login_required
#@ensure_csrf_cookie
def
upload_asset
(
request
,
org
,
course
,
coursename
):
def
upload_asset
(
request
,
org
,
course
,
coursename
):
'''
'''
cdodge: this method allows for POST uploading of files into the course asset library, which will
cdodge: this method allows for POST uploading of files into the course asset library, which will
...
@@ -842,6 +849,7 @@ def upload_asset(request, org, course, coursename):
...
@@ -842,6 +849,7 @@ def upload_asset(request, org, course, coursename):
response
[
'asset_url'
]
=
StaticContent
.
get_url_path_from_location
(
content
.
location
)
response
[
'asset_url'
]
=
StaticContent
.
get_url_path_from_location
(
content
.
location
)
return
response
return
response
'''
'''
This view will return all CMS users who are editors for the specified course
This view will return all CMS users who are editors for the specified course
'''
'''
...
@@ -874,6 +882,7 @@ def create_json_response(errmsg = None):
...
@@ -874,6 +882,7 @@ def create_json_response(errmsg = None):
return
resp
return
resp
'''
'''
This POST-back view will add a user - specified by email - to the list of editors for
This POST-back view will add a user - specified by email - to the list of editors for
the specified course
the specified course
...
@@ -906,6 +915,7 @@ def add_user(request, location):
...
@@ -906,6 +915,7 @@ def add_user(request, location):
return
create_json_response
()
return
create_json_response
()
'''
'''
This POST-back view will remove a user - specified by email - from the list of editors for
This POST-back view will remove a user - specified by email - from the list of editors for
the specified course
the specified course
...
@@ -937,6 +947,7 @@ def remove_user(request, location):
...
@@ -937,6 +947,7 @@ def remove_user(request, location):
def
landing
(
request
,
org
,
course
,
coursename
):
def
landing
(
request
,
org
,
course
,
coursename
):
return
render_to_response
(
'temp-course-landing.html'
,
{})
return
render_to_response
(
'temp-course-landing.html'
,
{})
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
def
static_pages
(
request
,
org
,
course
,
coursename
):
def
static_pages
(
request
,
org
,
course
,
coursename
):
...
@@ -1040,6 +1051,7 @@ def edit_tabs(request, org, course, coursename):
...
@@ -1040,6 +1051,7 @@ def edit_tabs(request, org, course, coursename):
'components'
:
components
'components'
:
components
})
})
def
not_found
(
request
):
def
not_found
(
request
):
return
render_to_response
(
'error.html'
,
{
'error'
:
'404'
})
return
render_to_response
(
'error.html'
,
{
'error'
:
'404'
})
...
@@ -1075,6 +1087,7 @@ def course_info(request, org, course, name, provided_id=None):
...
@@ -1075,6 +1087,7 @@ def course_info(request, org, course, name, provided_id=None):
'handouts_location'
:
Location
([
'i4x'
,
org
,
course
,
'course_info'
,
'handouts'
])
.
url
()
'handouts_location'
:
Location
([
'i4x'
,
org
,
course
,
'course_info'
,
'handouts'
])
.
url
()
})
})
@expect_json
@expect_json
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
...
@@ -1172,6 +1185,7 @@ def get_course_settings(request, org, course, name):
...
@@ -1172,6 +1185,7 @@ def get_course_settings(request, org, course, name):
"section"
:
"details"
})
"section"
:
"details"
})
})
})
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
def
course_config_graders_page
(
request
,
org
,
course
,
name
):
def
course_config_graders_page
(
request
,
org
,
course
,
name
):
...
@@ -1195,6 +1209,7 @@ def course_config_graders_page(request, org, course, name):
...
@@ -1195,6 +1209,7 @@ def course_config_graders_page(request, org, course, name):
'course_details'
:
json
.
dumps
(
course_details
,
cls
=
CourseSettingsEncoder
)
'course_details'
:
json
.
dumps
(
course_details
,
cls
=
CourseSettingsEncoder
)
})
})
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
def
course_config_advanced_page
(
request
,
org
,
course
,
name
):
def
course_config_advanced_page
(
request
,
org
,
course
,
name
):
...
@@ -1218,6 +1233,7 @@ def course_config_advanced_page(request, org, course, name):
...
@@ -1218,6 +1233,7 @@ def course_config_advanced_page(request, org, course, name):
'advanced_dict'
:
json
.
dumps
(
CourseMetadata
.
fetch
(
location
)),
'advanced_dict'
:
json
.
dumps
(
CourseMetadata
.
fetch
(
location
)),
})
})
@expect_json
@expect_json
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
...
@@ -1249,6 +1265,7 @@ def course_settings_updates(request, org, course, name, section):
...
@@ -1249,6 +1265,7 @@ def course_settings_updates(request, org, course, name, section):
return
HttpResponse
(
json
.
dumps
(
manager
.
update_from_json
(
request
.
POST
),
cls
=
CourseSettingsEncoder
),
return
HttpResponse
(
json
.
dumps
(
manager
.
update_from_json
(
request
.
POST
),
cls
=
CourseSettingsEncoder
),
mimetype
=
"application/json"
)
mimetype
=
"application/json"
)
@expect_json
@expect_json
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
...
@@ -1283,7 +1300,7 @@ def course_grader_updates(request, org, course, name, grader_index=None):
...
@@ -1283,7 +1300,7 @@ def course_grader_updates(request, org, course, name, grader_index=None):
return
HttpResponse
(
json
.
dumps
(
CourseGradingModel
.
update_grader_from_json
(
Location
([
'i4x'
,
org
,
course
,
'course'
,
name
]),
request
.
POST
)),
return
HttpResponse
(
json
.
dumps
(
CourseGradingModel
.
update_grader_from_json
(
Location
([
'i4x'
,
org
,
course
,
'course'
,
name
]),
request
.
POST
)),
mimetype
=
"application/json"
)
mimetype
=
"application/json"
)
## NB: expect_json failed on ["key", "key2"] and json payload
## NB: expect_json failed on ["key", "key2"] and json payload
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
...
@@ -1374,6 +1391,7 @@ def asset_index(request, org, course, name):
...
@@ -1374,6 +1391,7 @@ def asset_index(request, org, course, name):
def
edge
(
request
):
def
edge
(
request
):
return
render_to_response
(
'university_profiles/edge.html'
,
{})
return
render_to_response
(
'university_profiles/edge.html'
,
{})
@login_required
@login_required
@expect_json
@expect_json
def
create_new_course
(
request
):
def
create_new_course
(
request
):
...
@@ -1429,6 +1447,7 @@ def create_new_course(request):
...
@@ -1429,6 +1447,7 @@ def create_new_course(request):
return
HttpResponse
(
json
.
dumps
({
'id'
:
new_course
.
location
.
url
()}))
return
HttpResponse
(
json
.
dumps
({
'id'
:
new_course
.
location
.
url
()}))
def
initialize_course_tabs
(
course
):
def
initialize_course_tabs
(
course
):
# set up the default tabs
# set up the default tabs
# I've added this because when we add static tabs, the LMS either expects a None for the tabs list or
# I've added this because when we add static tabs, the LMS either expects a None for the tabs list or
...
@@ -1446,6 +1465,7 @@ def initialize_course_tabs(course):
...
@@ -1446,6 +1465,7 @@ def initialize_course_tabs(course):
modulestore
(
'direct'
)
.
update_metadata
(
course
.
location
.
url
(),
course
.
own_metadata
)
modulestore
(
'direct'
)
.
update_metadata
(
course
.
location
.
url
(),
course
.
own_metadata
)
@ensure_csrf_cookie
@ensure_csrf_cookie
@login_required
@login_required
def
import_course
(
request
,
org
,
course
,
name
):
def
import_course
(
request
,
org
,
course
,
name
):
...
@@ -1523,6 +1543,7 @@ def import_course(request, org, course, name):
...
@@ -1523,6 +1543,7 @@ def import_course(request, org, course, name):
course_module
.
location
.
name
])
course_module
.
location
.
name
])
})
})
@ensure_csrf_cookie
@ensure_csrf_cookie
@login_required
@login_required
def
generate_export_course
(
request
,
org
,
course
,
name
):
def
generate_export_course
(
request
,
org
,
course
,
name
):
...
@@ -1574,6 +1595,7 @@ def export_course(request, org, course, name):
...
@@ -1574,6 +1595,7 @@ def export_course(request, org, course, name):
'successful_import_redirect_url'
:
''
'successful_import_redirect_url'
:
''
})
})
def
event
(
request
):
def
event
(
request
):
'''
'''
A noop to swallow the analytics call so that cms methods don't spook and poor developers looking at
A noop to swallow the analytics call so that cms methods don't spook and poor developers looking at
...
...
cms/djangoapps/models/settings/course_metadata.py
View file @
d85f7ac9
...
@@ -10,7 +10,7 @@ class CourseMetadata(object):
...
@@ -10,7 +10,7 @@ class CourseMetadata(object):
'''
'''
# __new_advanced_key__ is used by client not server; so, could argue against it being here
# __new_advanced_key__ is used by client not server; so, could argue against it being here
FILTERED_LIST
=
XModuleDescriptor
.
system_metadata_fields
+
[
'start'
,
'end'
,
'enrollment_start'
,
'enrollment_end'
,
'tabs'
,
'graceperiod'
,
'__new_advanced_key__'
]
FILTERED_LIST
=
XModuleDescriptor
.
system_metadata_fields
+
[
'start'
,
'end'
,
'enrollment_start'
,
'enrollment_end'
,
'tabs'
,
'graceperiod'
,
'__new_advanced_key__'
]
@classmethod
@classmethod
def
fetch
(
cls
,
course_location
):
def
fetch
(
cls
,
course_location
):
"""
"""
...
@@ -18,17 +18,17 @@ class CourseMetadata(object):
...
@@ -18,17 +18,17 @@ class CourseMetadata(object):
"""
"""
if
not
isinstance
(
course_location
,
Location
):
if
not
isinstance
(
course_location
,
Location
):
course_location
=
Location
(
course_location
)
course_location
=
Location
(
course_location
)
course
=
{}
course
=
{}
descriptor
=
get_modulestore
(
course_location
)
.
get_item
(
course_location
)
descriptor
=
get_modulestore
(
course_location
)
.
get_item
(
course_location
)
for
k
,
v
in
descriptor
.
metadata
.
iteritems
():
for
k
,
v
in
descriptor
.
metadata
.
iteritems
():
if
k
not
in
cls
.
FILTERED_LIST
:
if
k
not
in
cls
.
FILTERED_LIST
:
course
[
k
]
=
v
course
[
k
]
=
v
return
course
return
course
@classmethod
@classmethod
def
update_from_json
(
cls
,
course_location
,
jsondict
):
def
update_from_json
(
cls
,
course_location
,
jsondict
):
"""
"""
...
@@ -37,7 +37,7 @@ class CourseMetadata(object):
...
@@ -37,7 +37,7 @@ class CourseMetadata(object):
Ensures none of the fields are in the blacklist.
Ensures none of the fields are in the blacklist.
"""
"""
descriptor
=
get_modulestore
(
course_location
)
.
get_item
(
course_location
)
descriptor
=
get_modulestore
(
course_location
)
.
get_item
(
course_location
)
dirty
=
False
dirty
=
False
for
k
,
v
in
jsondict
.
iteritems
():
for
k
,
v
in
jsondict
.
iteritems
():
...
@@ -45,26 +45,26 @@ class CourseMetadata(object):
...
@@ -45,26 +45,26 @@ class CourseMetadata(object):
if
k
not
in
cls
.
FILTERED_LIST
and
(
k
not
in
descriptor
.
metadata
or
descriptor
.
metadata
[
k
]
!=
v
):
if
k
not
in
cls
.
FILTERED_LIST
and
(
k
not
in
descriptor
.
metadata
or
descriptor
.
metadata
[
k
]
!=
v
):
dirty
=
True
dirty
=
True
descriptor
.
metadata
[
k
]
=
v
descriptor
.
metadata
[
k
]
=
v
if
dirty
:
if
dirty
:
get_modulestore
(
course_location
)
.
update_metadata
(
course_location
,
descriptor
.
metadata
)
get_modulestore
(
course_location
)
.
update_metadata
(
course_location
,
descriptor
.
metadata
)
# Could just generate and return a course obj w/o doing any db reads, but I put the reads in as a means to confirm
# Could just generate and return a course obj w/o doing any db reads, but I put the reads in as a means to confirm
# it persisted correctly
# it persisted correctly
return
cls
.
fetch
(
course_location
)
return
cls
.
fetch
(
course_location
)
@classmethod
@classmethod
def
delete_key
(
cls
,
course_location
,
payload
):
def
delete_key
(
cls
,
course_location
,
payload
):
'''
'''
Remove the given metadata key(s) from the course. payload can be a single key or [key..]
Remove the given metadata key(s) from the course. payload can be a single key or [key..]
'''
'''
descriptor
=
get_modulestore
(
course_location
)
.
get_item
(
course_location
)
descriptor
=
get_modulestore
(
course_location
)
.
get_item
(
course_location
)
for
key
in
payload
[
'deleteKeys'
]:
for
key
in
payload
[
'deleteKeys'
]:
if
key
in
descriptor
.
metadata
:
if
key
in
descriptor
.
metadata
:
del
descriptor
.
metadata
[
key
]
del
descriptor
.
metadata
[
key
]
get_modulestore
(
course_location
)
.
update_metadata
(
course_location
,
descriptor
.
metadata
)
get_modulestore
(
course_location
)
.
update_metadata
(
course_location
,
descriptor
.
metadata
)
return
cls
.
fetch
(
course_location
)
return
cls
.
fetch
(
course_location
)
\ No newline at end of file
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