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
3b6b4668
Commit
3b6b4668
authored
Aug 20, 2014
by
Don Mitchell
Committed by
Ben McMorran
Aug 21, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
On rerun, override the course start date
LMS-11011
parent
85f5c49b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
5 deletions
+77
-5
cms/djangoapps/contentstore/tests/test_course_create_rerun.py
+67
-0
cms/djangoapps/contentstore/views/course.py
+10
-5
No files found.
cms/djangoapps/contentstore/tests/test_course_create_rerun.py
0 → 100644
View file @
3b6b4668
"""
Test view handler for rerun (and eventually create)
"""
from
django.test.client
import
RequestFactory
from
opaque_keys.edx.keys
import
CourseKey
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
student.roles
import
CourseInstructorRole
,
CourseStaffRole
from
student.tests.factories
import
UserFactory
from
contentstore.tests.utils
import
AjaxEnabledTestClient
,
parse_json
from
datetime
import
datetime
from
xmodule.course_module
import
CourseFields
class
TestCourseListing
(
ModuleStoreTestCase
):
"""
Unit tests for getting the list of courses for a logged in user
"""
def
setUp
(
self
):
"""
Add a user and a course
"""
super
(
TestCourseListing
,
self
)
.
setUp
()
# create and log in a staff user.
# create and log in a non-staff user
self
.
user
=
UserFactory
()
self
.
factory
=
RequestFactory
()
self
.
client
=
AjaxEnabledTestClient
()
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
'test'
)
source_course
=
CourseFactory
.
create
(
org
=
'origin'
,
number
=
'the_beginning'
,
run
=
'first'
,
display_name
=
'the one and only'
,
start
=
datetime
.
utcnow
()
)
self
.
source_course_key
=
source_course
.
id
for
role
in
[
CourseInstructorRole
,
CourseStaffRole
]:
role
(
self
.
source_course_key
)
.
add_users
(
self
.
user
)
def
tearDown
(
self
):
"""
Reverse the setup
"""
self
.
client
.
logout
()
ModuleStoreTestCase
.
tearDown
(
self
)
def
test_rerun
(
self
):
"""
Just testing the functionality the view handler adds over the tasks tested in test_clone_course
"""
response
=
self
.
client
.
ajax_post
(
'/course/'
,
{
'source_course_key'
:
unicode
(
self
.
source_course_key
),
'org'
:
self
.
source_course_key
.
org
,
'course'
:
self
.
source_course_key
.
course
,
'run'
:
'copy'
,
'display_name'
:
'not the same old name'
,
})
self
.
assertEqual
(
response
.
status_code
,
200
)
data
=
parse_json
(
response
)
dest_course_key
=
CourseKey
.
from_string
(
data
[
'destination_course_key'
])
self
.
assertEqual
(
dest_course_key
.
run
,
'copy'
)
dest_course
=
self
.
store
.
get_course
(
dest_course_key
)
self
.
assertEqual
(
dest_course
.
start
,
CourseFields
.
start
.
default
)
cms/djangoapps/contentstore/views/course.py
View file @
3b6b4668
...
...
@@ -67,6 +67,7 @@ from student import auth
from
course_action_state.models
import
CourseRerunState
,
CourseRerunUIStateManager
from
course_action_state.managers
import
CourseActionStateItemNotFoundError
from
microsite_configuration
import
microsite
from
xmodule.course_module
import
CourseFields
__all__
=
[
'course_info_handler'
,
'course_handler'
,
'course_info_update_handler'
,
...
...
@@ -508,24 +509,28 @@ def _create_or_rerun_course(request):
try
:
org
=
request
.
json
.
get
(
'org'
)
number
=
request
.
json
.
get
(
'number'
)
course
=
request
.
json
.
get
(
'number'
,
request
.
json
.
get
(
'course'
)
)
display_name
=
request
.
json
.
get
(
'display_name'
)
# force the start date for reruns and allow us to override start via the client
start
=
request
.
json
.
get
(
'start'
,
CourseFields
.
start
.
default
)
run
=
request
.
json
.
get
(
'run'
)
# allow/disable unicode characters in course_id according to settings
if
not
settings
.
FEATURES
.
get
(
'ALLOW_UNICODE_COURSE_ID'
):
if
_has_non_ascii_characters
(
org
)
or
_has_non_ascii_characters
(
number
)
or
_has_non_ascii_characters
(
run
):
if
_has_non_ascii_characters
(
org
)
or
_has_non_ascii_characters
(
course
)
or
_has_non_ascii_characters
(
run
):
return
JsonResponse
(
{
'error'
:
_
(
'Special characters not allowed in organization, course number, and course run.'
)},
status
=
400
)
fields
=
{
'display_name'
:
display_name
}
if
display_name
is
not
None
else
{}
fields
=
{
'start'
:
start
}
if
display_name
is
not
None
:
fields
[
'display_name'
]
=
display_name
if
'source_course_key'
in
request
.
json
:
return
_rerun_course
(
request
,
org
,
number
,
run
,
fields
)
return
_rerun_course
(
request
,
org
,
course
,
run
,
fields
)
else
:
return
_create_new_course
(
request
,
org
,
number
,
run
,
fields
)
return
_create_new_course
(
request
,
org
,
course
,
run
,
fields
)
except
DuplicateCourseError
:
return
JsonResponse
({
...
...
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