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
c7b049be
Commit
c7b049be
authored
Feb 16, 2016
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11558 from edx/aamir-khan/ECOM-3706-verify-now-button-issue-fix-rc
Aamir khan/ecom 3706 verify now button fix
parents
52b39ca4
b6604a3a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
17 deletions
+33
-17
lms/djangoapps/verify_student/tests/test_views.py
+31
-15
lms/djangoapps/verify_student/views.py
+2
-2
No files found.
lms/djangoapps/verify_student/tests/test_views.py
View file @
c7b049be
...
...
@@ -674,7 +674,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
@ddt.data
(
"verify_student_start_flow"
,
"verify_student_begin_flow"
)
def
test_verification_deadline
(
self
,
payment_flow
):
deadline
=
datetime
(
2999
,
1
,
2
,
tzinfo
=
pytz
.
UTC
)
deadline
=
datetime
.
now
(
tz
=
pytz
.
UTC
)
+
timedelta
(
days
=
360
)
course
=
self
.
_create_course
(
"verified"
)
# Set a deadline on the course mode AND on the verification deadline model.
...
...
@@ -687,10 +687,10 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
# Expect that the expiration date is set
response
=
self
.
_get_page
(
payment_flow
,
course
.
id
)
data
=
self
.
_get_page_data
(
response
)
self
.
assertEqual
(
data
[
'verification_deadline'
],
"Jan 02, 2999 at 00:00 UTC"
)
self
.
assertEqual
(
data
[
'verification_deadline'
],
deadline
.
strftime
(
"
%
b
%
d,
%
Y at
%
H:
%
M UTC"
)
)
def
test_course_mode_expired
(
self
):
deadline
=
datetime
(
1999
,
1
,
2
,
tzinfo
=
pytz
.
UTC
)
deadline
=
datetime
.
now
(
tz
=
pytz
.
UTC
)
+
timedelta
(
days
=-
360
)
course
=
self
.
_create_course
(
"verified"
)
# Set the upgrade deadline (course mode expiration) and verification deadline
...
...
@@ -705,22 +705,32 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
# to the student that the deadline has passed
response
=
self
.
_get_page
(
"verify_student_verify_now"
,
course
.
id
)
self
.
assertContains
(
response
,
"verification deadline"
)
self
.
assertContains
(
response
,
"Jan 02, 1999 at 00:00 UTC"
)
self
.
assertContains
(
response
,
deadline
.
strftime
(
"
%
b
%
d,
%
Y at
%
H:
%
M UTC"
)
)
@ddt.data
(
datetime
(
2999
,
1
,
2
,
tzinfo
=
pytz
.
UTC
),
None
)
@ddt.data
(
datetime
.
now
(
tz
=
pytz
.
UTC
)
+
timedelta
(
days
=
360
),
None
)
def
test_course_mode_expired_verification_deadline_in_future
(
self
,
verification_deadline
):
course
=
self
.
_create_course
(
"verified"
)
"""Verify that student can not upgrade in expired course mode."""
course_modes
=
(
"verified"
,
"credit"
)
course
=
self
.
_create_course
(
*
course_modes
)
# Set the upgrade deadline in the past, but the verification
# Set the upgrade deadline
of verified mode
in the past, but the verification
# deadline in the future.
self
.
_set_deadlines
(
course
.
id
,
upgrade_deadline
=
datetime
(
1999
,
1
,
2
,
tzinfo
=
pytz
.
UTC
),
upgrade_deadline
=
datetime
.
now
(
tz
=
pytz
.
UTC
)
+
timedelta
(
days
=-
360
),
verification_deadline
=
verification_deadline
,
)
# Set the upgrade deadline for credit mode in future.
self
.
_set_deadlines
(
course
.
id
,
upgrade_deadline
=
datetime
.
now
(
tz
=
pytz
.
UTC
)
+
timedelta
(
days
=
360
),
verification_deadline
=
verification_deadline
,
mode_slug
=
"credit"
)
# Try to pay or upgrade.
# We should get an error message since the deadline has passed.
# We should get an error message since the deadline has passed and did not allow
# directly sale of credit mode.
for
page_name
in
[
"verify_student_start_flow"
,
"verify_student_begin_flow"
,
"verify_student_upgrade_and_verify"
]:
...
...
@@ -738,9 +748,13 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
data
=
self
.
_get_page_data
(
response
)
self
.
assertEqual
(
data
[
'message_key'
],
PayAndVerifyView
.
VERIFY_NOW_MSG
)
# Check that the mode selected is expired verified mode not the credit mode
# because the direct enrollment to the credit mode is not allowed.
self
.
assertEqual
(
data
[
'course_mode_slug'
],
"verified"
)
# Check that the verification deadline (rather than the upgrade deadline) is displayed
if
verification_deadline
is
not
None
:
self
.
assertEqual
(
data
[
"verification_deadline"
],
"Jan 02, 2999 at 00:00 UTC"
)
self
.
assertEqual
(
data
[
"verification_deadline"
],
verification_deadline
.
strftime
(
"
%
b
%
d,
%
Y at
%
H:
%
M UTC"
)
)
else
:
self
.
assertEqual
(
data
[
"verification_deadline"
],
""
)
...
...
@@ -753,10 +767,12 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
# since it's a bad user experience
# to purchase a verified track and then not be able to verify,
# but if it happens we need to handle it gracefully.
upgrade_deadline_in_future
=
datetime
.
now
(
tz
=
pytz
.
UTC
)
+
timedelta
(
days
=
360
)
verification_deadline_in_past
=
datetime
.
now
(
tz
=
pytz
.
UTC
)
+
timedelta
(
days
=-
360
)
self
.
_set_deadlines
(
course
.
id
,
upgrade_deadline
=
datetime
(
2999
,
1
,
2
,
tzinfo
=
pytz
.
UTC
)
,
verification_deadline
=
datetime
(
1999
,
1
,
2
,
tzinfo
=
pytz
.
UTC
)
,
upgrade_deadline
=
upgrade_deadline_in_future
,
verification_deadline
=
verification_deadline_in_past
,
)
# Enroll as verified (simulate purchasing the verified enrollment)
...
...
@@ -767,7 +783,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
# message when we go to verify.
response
=
self
.
_get_page
(
"verify_student_verify_now"
,
course
.
id
)
self
.
assertContains
(
response
,
"verification deadline"
)
self
.
assertContains
(
response
,
"Jan 02, 1999 at 00:00 UTC"
)
self
.
assertContains
(
response
,
verification_deadline_in_past
.
strftime
(
"
%
b
%
d,
%
Y at
%
H:
%
M UTC"
)
)
@mock.patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
@ddt.data
(
"verify_student_start_flow"
,
"verify_student_begin_flow"
)
...
...
@@ -841,7 +857,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
attempt
.
created_at
=
datetime
.
now
(
pytz
.
UTC
)
-
timedelta
(
days
=
(
days_good_for
+
1
))
attempt
.
save
()
def
_set_deadlines
(
self
,
course_key
,
upgrade_deadline
=
None
,
verification_deadline
=
None
):
def
_set_deadlines
(
self
,
course_key
,
upgrade_deadline
=
None
,
verification_deadline
=
None
,
mode_slug
=
"verified"
):
"""
Set the upgrade and verification deadlines.
...
...
@@ -858,7 +874,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
"""
# Set the course mode expiration (same as the "upgrade" deadline)
mode
=
CourseMode
.
objects
.
get
(
course_id
=
course_key
,
mode_slug
=
"verified"
)
mode
=
CourseMode
.
objects
.
get
(
course_id
=
course_key
,
mode_slug
=
mode_slug
)
mode
.
expiration_datetime
=
upgrade_deadline
mode
.
save
()
...
...
lms/djangoapps/verify_student/views.py
View file @
c7b049be
...
...
@@ -522,9 +522,9 @@ class PayAndVerifyView(View):
if
mode
.
min_price
>
0
and
not
CourseMode
.
is_credit_mode
(
mode
):
return
mode
# Otherwise, find the first
expire
d mode
# Otherwise, find the first
non credit expired pai
d mode
for
mode
in
all_modes
[
course_key
]:
if
mode
.
min_price
>
0
:
if
mode
.
min_price
>
0
and
not
CourseMode
.
is_credit_mode
(
mode
)
:
return
mode
# Otherwise, return None and so the view knows to respond with a 404.
...
...
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