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
d394c052
Commit
d394c052
authored
Sep 19, 2017
by
Matthew Piatetsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Take users from track selection to course home instead of dashboard
LEARNER-2546
parent
18d8cd96
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
18 deletions
+46
-18
common/djangoapps/course_modes/tests/test_views.py
+33
-15
common/djangoapps/course_modes/views.py
+11
-1
common/test/acceptance/pages/lms/track_selection.py
+2
-2
No files found.
common/djangoapps/course_modes/tests/test_views.py
View file @
d394c052
...
@@ -4,11 +4,12 @@ Tests for course_modes views.
...
@@ -4,11 +4,12 @@ Tests for course_modes views.
import
decimal
import
decimal
import
unittest
import
unittest
from
datetime
import
datetime
from
datetime
import
datetime
,
timedelta
import
ddt
import
ddt
import
freezegun
import
freezegun
import
httpretty
import
httpretty
import
pytz
import
waffle
import
waffle
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
...
@@ -43,44 +44,61 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
...
@@ -43,44 +44,61 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
@patch.dict
(
settings
.
FEATURES
,
{
'MODE_CREATION_FOR_TESTING'
:
True
})
@patch.dict
(
settings
.
FEATURES
,
{
'MODE_CREATION_FOR_TESTING'
:
True
})
def
setUp
(
self
):
def
setUp
(
self
):
super
(
CourseModeViewTest
,
self
)
.
setUp
()
super
(
CourseModeViewTest
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
()
now
=
datetime
.
now
(
pytz
.
utc
)
day
=
timedelta
(
days
=
1
)
tomorrow
=
now
+
day
yesterday
=
now
-
day
# Create course that has not started yet and course that started
self
.
course
=
CourseFactory
.
create
(
start
=
tomorrow
)
self
.
course_that_started
=
CourseFactory
.
create
(
start
=
yesterday
)
self
.
user
=
UserFactory
.
create
(
username
=
"Bob"
,
email
=
"bob@example.com"
,
password
=
"edx"
)
self
.
user
=
UserFactory
.
create
(
username
=
"Bob"
,
email
=
"bob@example.com"
,
password
=
"edx"
)
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
"edx"
)
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
"edx"
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@httpretty.activate
@httpretty.activate
@ddt.data
(
@ddt.data
(
# is_active?, enrollment_mode, redirect?
# is_active?, enrollment_mode, redirect?, has_started
(
True
,
'verified'
,
True
),
(
True
,
'verified'
,
True
,
False
),
(
True
,
'honor'
,
False
),
(
True
,
'honor'
,
False
,
False
),
(
True
,
'audit'
,
False
),
(
True
,
'audit'
,
False
,
False
),
(
False
,
'verified'
,
False
),
(
True
,
'verified'
,
True
,
True
),
(
False
,
'honor'
,
False
),
(
True
,
'honor'
,
False
,
True
),
(
False
,
'audit'
,
False
),
(
True
,
'audit'
,
False
,
True
),
(
False
,
None
,
False
),
(
False
,
'verified'
,
False
,
False
),
(
False
,
'honor'
,
False
,
False
),
(
False
,
'audit'
,
False
,
False
),
(
False
,
None
,
False
,
False
),
)
)
@ddt.unpack
@ddt.unpack
def
test_redirect_to_dashboard
(
self
,
is_active
,
enrollment_mode
,
redirect
):
def
test_redirect_to_dashboard
(
self
,
is_active
,
enrollment_mode
,
redirect
,
has_started
):
# Configure whether course has started
# If it has go to course home instead of dashboard
course
=
self
.
course_that_started
if
has_started
else
self
.
course
# Create the course modes
# Create the course modes
for
mode
in
(
'audit'
,
'honor'
,
'verified'
):
for
mode
in
(
'audit'
,
'honor'
,
'verified'
):
CourseModeFactory
.
create
(
mode_slug
=
mode
,
course_id
=
self
.
course
.
id
)
CourseModeFactory
.
create
(
mode_slug
=
mode
,
course_id
=
course
.
id
)
# Enroll the user in the test course
# Enroll the user in the test course
if
enrollment_mode
is
not
None
:
if
enrollment_mode
is
not
None
:
CourseEnrollmentFactory
(
CourseEnrollmentFactory
(
is_active
=
is_active
,
is_active
=
is_active
,
mode
=
enrollment_mode
,
mode
=
enrollment_mode
,
course_id
=
self
.
course
.
id
,
course_id
=
course
.
id
,
user
=
self
.
user
user
=
self
.
user
)
)
# Configure whether we're upgrading or not
# Configure whether we're upgrading or not
url
=
reverse
(
'course_modes_choose'
,
args
=
[
unicode
(
self
.
course
.
id
)])
url
=
reverse
(
'course_modes_choose'
,
args
=
[
unicode
(
course
.
id
)])
response
=
self
.
client
.
get
(
url
)
response
=
self
.
client
.
get
(
url
)
# Check whether we were correctly redirected
# Check whether we were correctly redirected
if
redirect
:
if
redirect
:
self
.
assertRedirects
(
response
,
reverse
(
'dashboard'
))
if
has_started
:
self
.
assertRedirects
(
response
,
reverse
(
'openedx.course_experience.course_home'
,
kwargs
=
{
'course_id'
:
course
.
id
})
)
else
:
self
.
assertRedirects
(
response
,
reverse
(
'dashboard'
))
else
:
else
:
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
status_code
,
200
)
...
...
common/djangoapps/course_modes/views.py
View file @
d394c052
...
@@ -103,6 +103,8 @@ class ChooseModeView(View):
...
@@ -103,6 +103,8 @@ class ChooseModeView(View):
redirect_url
=
ecommerce_service
.
get_checkout_page_url
(
professional_mode
.
bulk_sku
)
redirect_url
=
ecommerce_service
.
get_checkout_page_url
(
professional_mode
.
bulk_sku
)
return
redirect
(
redirect_url
)
return
redirect
(
redirect_url
)
course
=
modulestore
()
.
get_course
(
course_key
)
# If there isn't a verified mode available, then there's nothing
# If there isn't a verified mode available, then there's nothing
# to do on this page. Send the user to the dashboard.
# to do on this page. Send the user to the dashboard.
if
not
CourseMode
.
has_verified_mode
(
modes
):
if
not
CourseMode
.
has_verified_mode
(
modes
):
...
@@ -110,12 +112,14 @@ class ChooseModeView(View):
...
@@ -110,12 +112,14 @@ class ChooseModeView(View):
# If a user has already paid, redirect them to the dashboard.
# If a user has already paid, redirect them to the dashboard.
if
is_active
and
(
enrollment_mode
in
CourseMode
.
VERIFIED_MODES
+
[
CourseMode
.
NO_ID_PROFESSIONAL_MODE
]):
if
is_active
and
(
enrollment_mode
in
CourseMode
.
VERIFIED_MODES
+
[
CourseMode
.
NO_ID_PROFESSIONAL_MODE
]):
# If the course has started redirect to course home instead
if
course
.
has_started
():
return
redirect
(
reverse
(
'openedx.course_experience.course_home'
,
kwargs
=
{
'course_id'
:
course_key
}))
return
redirect
(
reverse
(
'dashboard'
))
return
redirect
(
reverse
(
'dashboard'
))
donation_for_course
=
request
.
session
.
get
(
"donation_for_course"
,
{})
donation_for_course
=
request
.
session
.
get
(
"donation_for_course"
,
{})
chosen_price
=
donation_for_course
.
get
(
unicode
(
course_key
),
None
)
chosen_price
=
donation_for_course
.
get
(
unicode
(
course_key
),
None
)
course
=
modulestore
()
.
get_course
(
course_key
)
if
CourseEnrollment
.
is_enrollment_closed
(
request
.
user
,
course
):
if
CourseEnrollment
.
is_enrollment_closed
(
request
.
user
,
course
):
locale
=
to_locale
(
get_language
())
locale
=
to_locale
(
get_language
())
enrollment_end_date
=
format_datetime
(
course
.
enrollment_end
,
'short'
,
locale
=
locale
)
enrollment_end_date
=
format_datetime
(
course
.
enrollment_end
,
'short'
,
locale
=
locale
)
...
@@ -224,10 +228,16 @@ class ChooseModeView(View):
...
@@ -224,10 +228,16 @@ class ChooseModeView(View):
# system, such as third-party discovery. These workflows result in learners arriving
# system, such as third-party discovery. These workflows result in learners arriving
# directly at this screen, and they will not necessarily be pre-enrolled in the audit mode.
# directly at this screen, and they will not necessarily be pre-enrolled in the audit mode.
CourseEnrollment
.
enroll
(
request
.
user
,
course_key
,
CourseMode
.
AUDIT
)
CourseEnrollment
.
enroll
(
request
.
user
,
course_key
,
CourseMode
.
AUDIT
)
# If the course has started redirect to course home instead
if
course
.
has_started
():
return
redirect
(
reverse
(
'openedx.course_experience.course_home'
,
kwargs
=
{
'course_id'
:
course_key
}))
return
redirect
(
reverse
(
'dashboard'
))
return
redirect
(
reverse
(
'dashboard'
))
if
requested_mode
==
'honor'
:
if
requested_mode
==
'honor'
:
CourseEnrollment
.
enroll
(
user
,
course_key
,
mode
=
requested_mode
)
CourseEnrollment
.
enroll
(
user
,
course_key
,
mode
=
requested_mode
)
# If the course has started redirect to course home instead
if
course
.
has_started
():
return
redirect
(
reverse
(
'openedx.course_experience.course_home'
,
kwargs
=
{
'course_id'
:
course_key
}))
return
redirect
(
reverse
(
'dashboard'
))
return
redirect
(
reverse
(
'dashboard'
))
mode_info
=
allowed_modes
[
requested_mode
]
mode_info
=
allowed_modes
[
requested_mode
]
...
...
common/test/acceptance/pages/lms/track_selection.py
View file @
d394c052
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
from
bok_choy.page_object
import
PageObject
from
bok_choy.page_object
import
PageObject
from
common.test.acceptance.pages.lms
import
BASE_URL
from
common.test.acceptance.pages.lms
import
BASE_URL
from
common.test.acceptance.pages.lms.
dashboard
import
Dashboard
Page
from
common.test.acceptance.pages.lms.
course_home
import
CourseHome
Page
from
common.test.acceptance.pages.lms.pay_and_verify
import
PaymentAndVerificationFlow
from
common.test.acceptance.pages.lms.pay_and_verify
import
PaymentAndVerificationFlow
...
@@ -52,7 +52,7 @@ class TrackSelectionPage(PageObject):
...
@@ -52,7 +52,7 @@ class TrackSelectionPage(PageObject):
elif
mode
==
"audit"
:
elif
mode
==
"audit"
:
self
.
q
(
css
=
"input[name='audit_mode']"
)
.
click
()
self
.
q
(
css
=
"input[name='audit_mode']"
)
.
click
()
return
DashboardPage
(
self
.
browser
)
.
wait_for_page
()
return
CourseHomePage
(
self
.
browser
,
self
.
_course_id
)
.
wait_for_page
()
else
:
else
:
raise
ValueError
(
"Mode must be either 'audit' or 'verified'."
)
raise
ValueError
(
"Mode must be either 'audit' or 'verified'."
)
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