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
b8368617
Commit
b8368617
authored
Apr 13, 2015
by
Awais Qureshi
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7627 from edx/awais786/ECOM-1183-verification-expiry
ECOM-1183 fixing the
parents
b6265c44
b464542e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
7 deletions
+68
-7
common/djangoapps/student/helpers.py
+16
-6
common/djangoapps/student/tests/test_verification_status.py
+51
-0
lms/templates/dashboard/_dashboard_course_listing.html
+1
-1
No files found.
common/djangoapps/student/helpers.py
View file @
b8368617
...
@@ -106,6 +106,8 @@ def check_verify_status_by_course(user, course_enrollment_pairs, all_course_mode
...
@@ -106,6 +106,8 @@ def check_verify_status_by_course(user, course_enrollment_pairs, all_course_mode
user
,
queryset
=
verifications
user
,
queryset
=
verifications
)
)
recent_verification_datetime
=
None
for
course
,
enrollment
in
course_enrollment_pairs
:
for
course
,
enrollment
in
course_enrollment_pairs
:
# Get the verified mode (if any) for this course
# Get the verified mode (if any) for this course
...
@@ -122,8 +124,17 @@ def check_verify_status_by_course(user, course_enrollment_pairs, all_course_mode
...
@@ -122,8 +124,17 @@ def check_verify_status_by_course(user, course_enrollment_pairs, all_course_mode
# verification status.
# verification status.
if
verified_mode
is
not
None
and
enrollment
.
mode
in
CourseMode
.
VERIFIED_MODES
:
if
verified_mode
is
not
None
and
enrollment
.
mode
in
CourseMode
.
VERIFIED_MODES
:
deadline
=
verified_mode
.
expiration_datetime
deadline
=
verified_mode
.
expiration_datetime
relevant_verification
=
SoftwareSecurePhotoVerification
.
verification_for_datetime
(
deadline
,
verifications
)
relevant_verification
=
SoftwareSecurePhotoVerification
.
verification_for_datetime
(
deadline
,
verifications
)
# Picking the max verification datetime on each iteration only with approved status
if
relevant_verification
is
not
None
and
relevant_verification
.
status
==
"approved"
:
recent_verification_datetime
=
max
(
recent_verification_datetime
if
recent_verification_datetime
is
not
None
else
relevant_verification
.
expiration_datetime
,
relevant_verification
.
expiration_datetime
)
# By default, don't show any status related to verification
# By default, don't show any status related to verification
status
=
None
status
=
None
...
@@ -173,19 +184,18 @@ def check_verify_status_by_course(user, course_enrollment_pairs, all_course_mode
...
@@ -173,19 +184,18 @@ def check_verify_status_by_course(user, course_enrollment_pairs, all_course_mode
# Otherwise, leave the course out of the dictionary.
# Otherwise, leave the course out of the dictionary.
if
status
is
not
None
:
if
status
is
not
None
:
days_until_deadline
=
None
days_until_deadline
=
None
verification_good_until
=
None
now
=
datetime
.
now
(
UTC
)
now
=
datetime
.
now
(
UTC
)
if
deadline
is
not
None
and
deadline
>
now
:
if
deadline
is
not
None
and
deadline
>
now
:
days_until_deadline
=
(
deadline
-
now
)
.
days
days_until_deadline
=
(
deadline
-
now
)
.
days
if
relevant_verification
is
not
None
:
verification_good_until
=
relevant_verification
.
expiration_datetime
.
strftime
(
"
%
m/
%
d/
%
Y"
)
status_by_course
[
course
.
id
]
=
{
status_by_course
[
course
.
id
]
=
{
'status'
:
status
,
'status'
:
status
,
'days_until_deadline'
:
days_until_deadline
,
'days_until_deadline'
:
days_until_deadline
'verification_good_until'
:
verification_good_until
}
}
if
recent_verification_datetime
:
for
key
,
value
in
status_by_course
.
iteritems
():
# pylint: disable=unused-variable
status_by_course
[
key
][
'verification_good_until'
]
=
recent_verification_datetime
.
strftime
(
"
%
m/
%
d/
%
Y"
)
return
status_by_course
return
status_by_course
common/djangoapps/student/tests/test_verification_status.py
View file @
b8368617
...
@@ -7,6 +7,7 @@ from mock import patch
...
@@ -7,6 +7,7 @@ from mock import patch
from
pytz
import
UTC
from
pytz
import
UTC
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
from
django.conf
import
settings
from
reverification.tests.factories
import
MidcourseReverificationWindowFactory
from
student.helpers
import
(
from
student.helpers
import
(
VERIFY_STATUS_NEED_TO_VERIFY
,
VERIFY_STATUS_NEED_TO_VERIFY
,
...
@@ -224,6 +225,56 @@ class TestCourseVerificationStatus(UrlResetMixin, ModuleStoreTestCase):
...
@@ -224,6 +225,56 @@ class TestCourseVerificationStatus(UrlResetMixin, ModuleStoreTestCase):
# Expect that the user's displayed enrollment mode is verified.
# Expect that the user's displayed enrollment mode is verified.
self
.
_assert_course_verification_status
(
VERIFY_STATUS_APPROVED
)
self
.
_assert_course_verification_status
(
VERIFY_STATUS_APPROVED
)
def
test_with_two_verifications
(
self
):
# checking if a user has two verification and but most recent verification course deadline is expired
self
.
_setup_mode_and_enrollment
(
self
.
FUTURE
,
"verified"
)
# The student has an approved verification
attempt
=
SoftwareSecurePhotoVerification
.
objects
.
create
(
user
=
self
.
user
)
attempt
.
mark_ready
()
attempt
.
submit
()
attempt
.
approve
()
# Making created at to previous date to differentiate with 2nd attempt.
attempt
.
created_at
=
datetime
.
now
(
UTC
)
-
timedelta
(
days
=
1
)
attempt
.
save
()
# Expect that the successfully verified message is shown
self
.
_assert_course_verification_status
(
VERIFY_STATUS_APPROVED
)
# Check that the "verification good until" date is displayed
response
=
self
.
client
.
get
(
self
.
dashboard_url
)
self
.
assertContains
(
response
,
attempt
.
expiration_datetime
.
strftime
(
"
%
m/
%
d/
%
Y"
))
# Adding another verification with different course.
# Its created_at is greater than course deadline.
course2
=
CourseFactory
.
create
()
CourseModeFactory
(
course_id
=
course2
.
id
,
mode_slug
=
"verified"
,
expiration_datetime
=
self
.
PAST
)
CourseEnrollmentFactory
(
course_id
=
course2
.
id
,
user
=
self
.
user
,
mode
=
"verified"
)
window
=
MidcourseReverificationWindowFactory
(
course_id
=
course2
.
id
)
# The student has an approved verification
attempt2
=
SoftwareSecurePhotoVerification
.
objects
.
create
(
user
=
self
.
user
)
attempt2
.
mark_ready
()
attempt2
.
submit
()
attempt2
.
approve
()
attempt2
.
window
=
window
attempt2
.
save
()
# Mark the attemp2 as approved so its date will appear on dasboard.
self
.
_assert_course_verification_status
(
VERIFY_STATUS_APPROVED
)
response2
=
self
.
client
.
get
(
self
.
dashboard_url
)
self
.
assertContains
(
response2
,
attempt2
.
expiration_datetime
.
strftime
(
"
%
m/
%
d/
%
Y"
))
self
.
assertEqual
(
response2
.
content
.
count
(
attempt2
.
expiration_datetime
.
strftime
(
"
%
m/
%
d/
%
Y"
)),
2
)
def
_setup_mode_and_enrollment
(
self
,
deadline
,
enrollment_mode
):
def
_setup_mode_and_enrollment
(
self
,
deadline
,
enrollment_mode
):
"""Create a course mode and enrollment.
"""Create a course mode and enrollment.
...
...
lms/templates/dashboard/_dashboard_course_listing.html
View file @
b8368617
...
@@ -277,7 +277,7 @@ from student.helpers import (
...
@@ -277,7 +277,7 @@ from student.helpers import (
<p
class=
"message-copy"
>
${_('Thanks for your patience as we process your request.')}
</p>
<p
class=
"message-copy"
>
${_('Thanks for your patience as we process your request.')}
</p>
% elif verification_status['status'] == VERIFY_STATUS_APPROVED:
% elif verification_status['status'] == VERIFY_STATUS_APPROVED:
<h4
class=
"message-title"
>
${_('You have already verified your ID!')}
</h4>
<h4
class=
"message-title"
>
${_('You have already verified your ID!')}
</h4>
% if verification_status
['verification_good_until']
is not None:
% if verification_status
.get('verification_good_until')
is not None:
<p
class=
"message-copy"
>
${_('Your verification status is good until {date}.').format(date=verification_status['verification_good_until'])}
<p
class=
"message-copy"
>
${_('Your verification status is good until {date}.').format(date=verification_status['verification_good_until'])}
% endif
% endif
% elif verification_status['status'] == VERIFY_STATUS_NEED_TO_REVERIFY:
% elif verification_status['status'] == VERIFY_STATUS_NEED_TO_REVERIFY:
...
...
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