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
5ad126d6
Commit
5ad126d6
authored
Aug 31, 2015
by
Kevin Falcone
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9505 from edx/jibsheet/delete_course-memory-improvement
Optimize memory and CPU usage.
parents
035bf4fb
e3c66f55
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
43 deletions
+11
-43
AUTHORS
+2
-2
cms/djangoapps/contentstore/management/commands/delete_course.py
+1
-15
cms/djangoapps/contentstore/management/commands/tests/test_delete_course.py
+8
-11
common/lib/xmodule/xmodule/modulestore/mixed.py
+0
-15
No files found.
AUTHORS
View file @
5ad126d6
...
...
@@ -233,4 +233,5 @@ Dongwook Yoon <dy252@cornell.edu>
Awais Qureshi <awais.qureshi@arbisoft.com>
Eric Fischer <efischer@edx.org>
Brian Beggs <macdiesel@gmail.com>
Bill DeRusha <bill@edx.org>
\ No newline at end of file
Bill DeRusha <bill@edx.org>
Kevin Falcone <kevin@edx.org>
cms/djangoapps/contentstore/management/commands/delete_course.py
View file @
5ad126d6
...
...
@@ -18,18 +18,6 @@ from xmodule.modulestore import ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
def
print_out_all_courses
():
"""
Print out all the courses available in the course_key format so that
the user can correct any course_key mistakes
"""
courses
=
modulestore
()
.
get_courses_keys
()
print
'Available courses:'
for
course
in
courses
:
print
str
(
course
)
print
''
class
Command
(
BaseCommand
):
"""
Delete a MongoDB backed course
...
...
@@ -58,8 +46,6 @@ class Command(BaseCommand):
elif
len
(
args
)
>
2
:
raise
CommandError
(
"Too many arguments! Expected <course_key> <commit>"
)
print_out_all_courses
()
if
not
modulestore
()
.
get_course
(
course_key
):
raise
CommandError
(
"Course with '
%
s' key not found."
%
args
[
0
])
...
...
@@ -67,4 +53,4 @@ class Command(BaseCommand):
if
query_yes_no
(
"Deleting course {0}. Confirm?"
.
format
(
course_key
),
default
=
"no"
):
if
query_yes_no
(
"Are you sure. This action cannot be undone!"
,
default
=
"no"
):
delete_course_and_groups
(
course_key
,
ModuleStoreEnum
.
UserID
.
mgmt_command
)
print
_out_all_courses
(
)
print
"Deleted course {}"
.
format
(
course_key
)
cms/djangoapps/contentstore/management/commands/tests/test_delete_course.py
View file @
5ad126d6
...
...
@@ -5,6 +5,7 @@ Unittests for deleting a course in an chosen modulestore
import
unittest
import
mock
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
django.core.management
import
CommandError
from
contentstore.management.commands.delete_course
import
Command
# pylint: disable=import-error
from
contentstore.tests.utils
import
CourseTestCase
# pylint: disable=import-error
...
...
@@ -94,27 +95,23 @@ class DeleteCourseTest(CourseTestCase):
run
=
course_run
)
def
test_courses_keys_listing
(
self
):
"""
Test if the command lists out available course key courses
"""
courses
=
[
str
(
key
)
for
key
in
modulestore
()
.
get_courses_keys
()]
self
.
assertIn
(
"TestX/TS01/2015_Q1"
,
courses
)
def
test_course_key_not_found
(
self
):
"""
Test for when a non-existing course key is entered
"""
errstring
=
"Course with 'TestX/TS01/2015_Q7' key not found."
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
self
.
command
.
handle
(
"TestX/TS01/2015_Q7"
,
"commit"
)
self
.
command
.
handle
(
'TestX/TS01/2015_Q7'
,
"commit"
)
def
test_course_deleted
(
self
):
"""
Testing if the entered course was deleted
"""
#Test if the course that is about to be deleted exists
self
.
assertIsNotNone
(
modulestore
()
.
get_course
(
SlashSeparatedCourseKey
(
"TestX"
,
"TS01"
,
"2015_Q1"
)))
with
mock
.
patch
(
self
.
YESNO_PATCH_LOCATION
)
as
patched_yes_no
:
patched_yes_no
.
return_value
=
True
self
.
command
.
handle
(
"TestX/TS01/2015_Q1"
,
"commit"
)
courses
=
[
unicode
(
key
)
for
key
in
modulestore
()
.
get_courses_keys
()]
self
.
assertNotIn
(
"TestX/TS01/2015_Q1"
,
courses
)
self
.
command
.
handle
(
'TestX/TS01/2015_Q1'
,
"commit"
)
self
.
assertIsNone
(
modulestore
()
.
get_course
(
SlashSeparatedCourseKey
(
"TestX"
,
"TS01"
,
"2015_Q1"
)))
common/lib/xmodule/xmodule/modulestore/mixed.py
View file @
5ad126d6
...
...
@@ -281,21 +281,6 @@ class MixedModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase):
return
courses
.
values
()
@strip_key
def
get_courses_keys
(
self
,
**
kwargs
):
'''
Returns a list containing the top level XModuleDescriptors keys of the courses in this modulestore.
'''
courses
=
{}
for
store
in
self
.
modulestores
:
# filter out ones which were fetched from earlier stores but locations may not be ==
for
course
in
store
.
get_courses
(
**
kwargs
):
course_id
=
self
.
_clean_locator_for_mapping
(
course
.
id
)
if
course_id
not
in
courses
:
# course is indeed unique. save it in result
courses
[
course_id
]
=
course
return
courses
.
keys
()
@strip_key
def
get_libraries
(
self
,
**
kwargs
):
"""
Returns a list containing the top level XBlock of the libraries (LibraryRoot) in this modulestore.
...
...
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