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
b412dd57
Commit
b412dd57
authored
May 13, 2013
by
Steve Strassmann
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2026 from edx/bug/straz/pep8
pep8 cleanups
parents
c4c3b202
d26dc957
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
40 deletions
+53
-40
cms/djangoapps/contentstore/views/__init__.py
+2
-6
cms/djangoapps/contentstore/views/assets.py
+18
-18
cms/djangoapps/contentstore/views/component.py
+9
-3
cms/djangoapps/contentstore/views/course.py
+22
-11
cms/djangoapps/contentstore/views/preview.py
+2
-2
No files found.
cms/djangoapps/contentstore/views/__init__.py
View file @
b412dd57
# pylint: disable=W0401, W0511
# pylint: disable=W0401, W0511
# TODO: component.py should explicitly enumerate exports with __all__
from
.component
import
*
# TODO: course.py should explicitly enumerate exports with __all__
from
.course
import
*
# Disable warnings about import from wildcard
# Disable warnings about import from wildcard
# All files below declare exports with __all__
# All files below declare exports with __all__
from
.assets
import
*
from
.assets
import
*
from
.checklist
import
*
from
.checklist
import
*
from
.component
import
*
from
.course
import
*
from
.error
import
*
from
.error
import
*
from
.item
import
*
from
.item
import
*
from
.preview
import
*
from
.preview
import
*
...
...
cms/djangoapps/contentstore/views/assets.py
View file @
b412dd57
...
@@ -59,12 +59,12 @@ def asset_index(request, org, course, name):
...
@@ -59,12 +59,12 @@ def asset_index(request, org, course, name):
asset_display
=
[]
asset_display
=
[]
for
asset
in
assets
:
for
asset
in
assets
:
id
=
asset
[
'_id'
]
asset_
id
=
asset
[
'_id'
]
display_info
=
{}
display_info
=
{}
display_info
[
'displayname'
]
=
asset
[
'displayname'
]
display_info
[
'displayname'
]
=
asset
[
'displayname'
]
display_info
[
'uploadDate'
]
=
get_default_time_display
(
asset
[
'uploadDate'
]
.
timetuple
())
display_info
[
'uploadDate'
]
=
get_default_time_display
(
asset
[
'uploadDate'
]
.
timetuple
())
asset_location
=
StaticContent
.
compute_location
(
id
[
'org'
],
id
[
'course'
],
id
[
'name'
])
asset_location
=
StaticContent
.
compute_location
(
asset_id
[
'org'
],
asset_id
[
'course'
],
asset_
id
[
'name'
])
display_info
[
'url'
]
=
StaticContent
.
get_url_path_from_location
(
asset_location
)
display_info
[
'url'
]
=
StaticContent
.
get_url_path_from_location
(
asset_location
)
# note, due to the schema change we may not have a 'thumbnail_location' in the result set
# note, due to the schema change we may not have a 'thumbnail_location' in the result set
...
@@ -171,13 +171,13 @@ def import_course(request, org, course, name):
...
@@ -171,13 +171,13 @@ def import_course(request, org, course, name):
temp_file
.
write
(
chunk
)
temp_file
.
write
(
chunk
)
temp_file
.
close
()
temp_file
.
close
()
t
f
=
tarfile
.
open
(
temp_filepath
)
t
ar_file
=
tarfile
.
open
(
temp_filepath
)
t
f
.
extractall
(
course_dir
+
'/'
)
t
ar_file
.
extractall
(
course_dir
+
'/'
)
# find the 'course.xml' file
# find the 'course.xml' file
for
r
,
d
,
f
in
os
.
walk
(
course_dir
):
for
dirpath
,
_dirnames
,
filenames
in
os
.
walk
(
course_dir
):
for
files
in
f
:
for
files
in
f
ilenames
:
if
files
==
'course.xml'
:
if
files
==
'course.xml'
:
break
break
if
files
==
'course.xml'
:
if
files
==
'course.xml'
:
...
@@ -186,17 +186,17 @@ def import_course(request, org, course, name):
...
@@ -186,17 +186,17 @@ def import_course(request, org, course, name):
if
files
!=
'course.xml'
:
if
files
!=
'course.xml'
:
return
HttpResponse
(
json
.
dumps
({
'ErrMsg'
:
'Could not find the course.xml file in the package.'
}))
return
HttpResponse
(
json
.
dumps
({
'ErrMsg'
:
'Could not find the course.xml file in the package.'
}))
logging
.
debug
(
'found course.xml at {0}'
.
format
(
r
))
logging
.
debug
(
'found course.xml at {0}'
.
format
(
dirpath
))
if
r
!=
course_dir
:
if
dirpath
!=
course_dir
:
for
fname
in
os
.
listdir
(
r
):
for
fname
in
os
.
listdir
(
dirpath
):
shutil
.
move
(
r
/
fname
,
course_dir
)
shutil
.
move
(
dirpath
/
fname
,
course_dir
)
module_store
,
course_items
=
import_from_xml
(
modulestore
(
'direct'
),
settings
.
GITHUB_REPO_ROOT
,
_
module_store
,
course_items
=
import_from_xml
(
modulestore
(
'direct'
),
settings
.
GITHUB_REPO_ROOT
,
[
course_subdir
],
load_error_modules
=
False
,
[
course_subdir
],
load_error_modules
=
False
,
static_content_store
=
contentstore
(),
static_content_store
=
contentstore
(),
target_location_namespace
=
Location
(
location
),
target_location_namespace
=
Location
(
location
),
draft_store
=
modulestore
())
draft_store
=
modulestore
())
# we can blow this away when we're done importing.
# we can blow this away when we're done importing.
shutil
.
rmtree
(
course_dir
)
shutil
.
rmtree
(
course_dir
)
...
@@ -234,9 +234,9 @@ def generate_export_course(request, org, course, name):
...
@@ -234,9 +234,9 @@ def generate_export_course(request, org, course, name):
#filename = root_dir / name + '.tar.gz'
#filename = root_dir / name + '.tar.gz'
logging
.
debug
(
'tar file being generated at {0}'
.
format
(
export_file
.
name
))
logging
.
debug
(
'tar file being generated at {0}'
.
format
(
export_file
.
name
))
t
f
=
tarfile
.
open
(
name
=
export_file
.
name
,
mode
=
'w:gz'
)
t
ar_file
=
tarfile
.
open
(
name
=
export_file
.
name
,
mode
=
'w:gz'
)
t
f
.
add
(
root_dir
/
name
,
arcname
=
name
)
t
ar_file
.
add
(
root_dir
/
name
,
arcname
=
name
)
t
f
.
close
()
t
ar_file
.
close
()
# remove temp dir
# remove temp dir
shutil
.
rmtree
(
root_dir
/
name
)
shutil
.
rmtree
(
root_dir
/
name
)
...
...
cms/djangoapps/contentstore/views/component.py
View file @
b412dd57
...
@@ -26,9 +26,15 @@ from models.settings.course_grading import CourseGradingModel
...
@@ -26,9 +26,15 @@ from models.settings.course_grading import CourseGradingModel
from
.requests
import
get_request_method
,
_xmodule_recurse
from
.requests
import
get_request_method
,
_xmodule_recurse
from
.access
import
has_access
from
.access
import
has_access
# TODO: should explicitly enumerate exports with __all__
__all__
=
[
'OPEN_ENDED_COMPONENT_TYPES'
,
'ADVANCED_COMPONENT_POLICY_KEY'
,
# to install PIL on MacOSX: 'easy_install http://dist.repoze.org/PIL-1.1.6.tar.gz'
'edit_subsection'
,
'edit_unit'
,
'assignment_type_update'
,
'create_draft'
,
'publish_draft'
,
'unpublish_unit'
,
'module_info'
]
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
...
cms/djangoapps/contentstore/views/course.py
View file @
b412dd57
"""
Views related to operations on course objects
"""
import
json
import
json
import
time
import
time
...
@@ -10,16 +13,17 @@ from django.core.urlresolvers import reverse
...
@@ -10,16 +13,17 @@ from django.core.urlresolvers import reverse
from
mitxmako.shortcuts
import
render_to_response
from
mitxmako.shortcuts
import
render_to_response
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
\
from
xmodule.modulestore.exceptions
\
InvalidLocationError
import
ItemNotFoundError
,
InvalidLocationError
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
from
contentstore.course_info_model
import
get_course_updates
,
\
from
contentstore.course_info_model
\
update_course_updates
,
delete_course_update
import
get_course_updates
,
update_course_updates
,
delete_course_update
from
contentstore.utils
import
get_lms_link_for_item
,
\
from
contentstore.utils
\
add_open_ended_panel_tab
,
remove_open_ended_panel_tab
import
get_lms_link_for_item
,
add_open_ended_panel_tab
,
\
from
models.settings.course_details
import
CourseDetails
,
\
remove_open_ended_panel_tab
CourseSettingsEncoder
from
models.settings.course_details
\
import
CourseDetails
,
CourseSettingsEncoder
from
models.settings.course_grading
import
CourseGradingModel
from
models.settings.course_grading
import
CourseGradingModel
from
models.settings.course_metadata
import
CourseMetadata
from
models.settings.course_metadata
import
CourseMetadata
from
auth.authz
import
create_all_course_groups
from
auth.authz
import
create_all_course_groups
...
@@ -30,7 +34,13 @@ from .requests import get_request_method
...
@@ -30,7 +34,13 @@ from .requests import get_request_method
from
.tabs
import
initialize_course_tabs
from
.tabs
import
initialize_course_tabs
from
.component
import
OPEN_ENDED_COMPONENT_TYPES
,
ADVANCED_COMPONENT_POLICY_KEY
from
.component
import
OPEN_ENDED_COMPONENT_TYPES
,
ADVANCED_COMPONENT_POLICY_KEY
# TODO: should explicitly enumerate exports with __all__
__all__
=
[
'course_index'
,
'create_new_course'
,
'course_info'
,
'course_info_updates'
,
'get_course_settings'
,
'course_config_graders_page'
,
'course_config_advanced_page'
,
'course_settings_updates'
,
'course_grader_updates'
,
'course_advanced_updates'
]
@login_required
@login_required
...
@@ -87,8 +97,9 @@ def create_new_course(request):
...
@@ -87,8 +97,9 @@ def create_new_course(request):
try
:
try
:
dest_location
=
Location
(
'i4x'
,
org
,
number
,
'course'
,
Location
.
clean
(
display_name
))
dest_location
=
Location
(
'i4x'
,
org
,
number
,
'course'
,
Location
.
clean
(
display_name
))
except
InvalidLocationError
as
e
:
except
InvalidLocationError
as
error
:
return
HttpResponse
(
json
.
dumps
({
'ErrMsg'
:
"Unable to create course '"
+
display_name
+
"'.
\n\n
"
+
e
.
message
}))
return
HttpResponse
(
json
.
dumps
({
'ErrMsg'
:
"Unable to create course '"
+
display_name
+
"'.
\n\n
"
+
error
.
message
}))
# see if the course already exists
# see if the course already exists
existing_course
=
None
existing_course
=
None
...
...
cms/djangoapps/contentstore/views/preview.py
View file @
b412dd57
...
@@ -96,7 +96,7 @@ def preview_module_system(request, preview_id, descriptor):
...
@@ -96,7 +96,7 @@ def preview_module_system(request, preview_id, descriptor):
return
ModuleSystem
(
return
ModuleSystem
(
ajax_url
=
reverse
(
'preview_dispatch'
,
args
=
[
preview_id
,
descriptor
.
location
.
url
(),
''
])
.
rstrip
(
'/'
),
ajax_url
=
reverse
(
'preview_dispatch'
,
args
=
[
preview_id
,
descriptor
.
location
.
url
(),
''
])
.
rstrip
(
'/'
),
# TODO (cpennington): Do we want to track how instructors are using the preview problems?
# TODO (cpennington): Do we want to track how instructors are using the preview problems?
track_function
=
lambda
type
,
event
:
None
,
track_function
=
lambda
event_
type
,
event
:
None
,
filestore
=
descriptor
.
system
.
resources_fs
,
filestore
=
descriptor
.
system
.
resources_fs
,
get_module
=
partial
(
get_preview_module
,
request
,
preview_id
),
get_module
=
partial
(
get_preview_module
,
request
,
preview_id
),
render_template
=
render_from_lms
,
render_template
=
render_from_lms
,
...
@@ -171,7 +171,7 @@ def get_module_previews(request, descriptor):
...
@@ -171,7 +171,7 @@ def get_module_previews(request, descriptor):
descriptor: An XModuleDescriptor
descriptor: An XModuleDescriptor
"""
"""
preview_html
=
[]
preview_html
=
[]
for
idx
,
(
instance_state
,
shared_state
)
in
enumerate
(
descriptor
.
get_sample_state
()):
for
idx
,
(
_instance_state
,
_
shared_state
)
in
enumerate
(
descriptor
.
get_sample_state
()):
module
=
load_preview_module
(
request
,
str
(
idx
),
descriptor
)
module
=
load_preview_module
(
request
,
str
(
idx
),
descriptor
)
preview_html
.
append
(
module
.
get_html
())
preview_html
.
append
(
module
.
get_html
())
return
preview_html
return
preview_html
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