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
8afb3605
Commit
8afb3605
authored
Oct 06, 2015
by
Edward Zarecor
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10060 from edx/release
Release
parents
dc5ed684
7427d82c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
128 additions
and
7 deletions
+128
-7
lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py
+21
-3
lms/djangoapps/verify_student/management/commands/set_software_secure_status.py
+60
-0
lms/djangoapps/verify_student/migrations/0013_auto__add_field_softwaresecurephotoverification_copy_id_photo_from.py
+0
-0
lms/djangoapps/verify_student/migrations/0014_set_copy_id_photo_from.py
+0
-0
lms/djangoapps/verify_student/models.py
+9
-2
lms/djangoapps/verify_student/tests/test_models.py
+32
-0
lms/djangoapps/verify_student/tests/test_views.py
+6
-2
No files found.
lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py
View file @
8afb3605
...
...
@@ -11,13 +11,31 @@ class Command(BaseCommand):
This method finds those PhotoVerifications with a status of
MUST_RETRY and attempts to verify them.
"""
help
=
'Retries SoftwareSecurePhotoVerifications that are in a state of
\'
must_retry
\'
'
args
=
"<SoftwareSecurePhotoVerification id, SoftwareSecurePhotoVerification id, ...>"
help
=
(
"Retries SoftwareSecurePhotoVerifications passed as "
"arguments, or if no arguments are supplied, all that "
"are in a state of 'must_retry'"
)
def
handle
(
self
,
*
args
,
**
options
):
attempts_to_retry
=
SoftwareSecurePhotoVerification
.
objects
.
filter
(
status
=
'must_retry'
)
if
args
:
attempts_to_retry
=
SoftwareSecurePhotoVerification
.
objects
.
filter
(
receipt_id__in
=
args
)
force_must_retry
=
True
else
:
attempts_to_retry
=
SoftwareSecurePhotoVerification
.
objects
.
filter
(
status
=
'must_retry'
)
force_must_retry
=
False
print
(
"Attempting to retry {0} failed PhotoVerification submissions"
.
format
(
len
(
attempts_to_retry
)))
for
index
,
attempt
in
enumerate
(
attempts_to_retry
):
print
(
"Retrying submission #{0} (ID: {1}, User: {2})"
.
format
(
index
,
attempt
.
id
,
attempt
.
user
))
attempt
.
submit
()
# Set the attempts status to 'must_retry' so that we can re-submit it
if
force_must_retry
:
attempt
.
status
=
'must_retry'
attempt
.
submit
(
copy_id_photo_from
=
attempt
.
copy_id_photo_from
)
print
(
"Retry result: {0}"
.
format
(
attempt
.
status
))
print
(
"Done resubmitting failed photo verifications"
)
lms/djangoapps/verify_student/management/commands/set_software_secure_status.py
0 → 100644
View file @
8afb3605
"""
Manually set Software Secure verification status.
"""
import
sys
from
django.core.management.base
import
BaseCommand
from
verify_student.models
import
(
SoftwareSecurePhotoVerification
,
VerificationCheckpoint
,
VerificationStatus
)
class
Command
(
BaseCommand
):
"""
Command to trigger the actions that would normally follow Software Secure
returning with the results of a photo verification.
"""
args
=
"<{approved, denied}, SoftwareSecurePhotoVerification id, [reason_for_denial]>"
def
handle
(
self
,
*
args
,
**
kwargs
):
# pylint: disable=unused-argument
from
verify_student.views
import
_set_user_requirement_status
status_to_set
=
args
[
0
]
receipt_id
=
args
[
1
]
try
:
attempt
=
SoftwareSecurePhotoVerification
.
objects
.
get
(
receipt_id
=
receipt_id
)
except
SoftwareSecurePhotoVerification
.
DoesNotExist
:
self
.
stderr
.
write
(
'SoftwareSecurePhotoVerification with id {id} could not be found.
\n
'
.
format
(
id
=
receipt_id
)
)
sys
.
exit
(
1
)
if
status_to_set
==
'approved'
:
self
.
stdout
.
write
(
'Approving verification for {id}.
\n
'
.
format
(
id
=
receipt_id
))
attempt
.
approve
()
_set_user_requirement_status
(
attempt
,
'reverification'
,
'satisfied'
)
elif
status_to_set
==
'denied'
:
self
.
stdout
.
write
(
'Denying verification for {id}.
\n
'
.
format
(
id
=
receipt_id
))
if
len
(
args
)
>=
3
:
reason_for_denial
=
args
[
2
]
else
:
reason_for_denial
=
'Denied via management command.'
attempt
.
deny
(
reason_for_denial
)
_set_user_requirement_status
(
attempt
,
'reverification'
,
'failed'
,
reason_for_denial
)
else
:
self
.
stdout
.
write
(
'Cannot set id {id} to unrecognized status {status}'
.
format
(
id
=
receipt_id
,
status
=
status_to_set
))
sys
.
exit
(
1
)
checkpoints
=
VerificationCheckpoint
.
objects
.
filter
(
photo_verification
=
attempt
)
.
all
()
VerificationStatus
.
add_status_from_checkpoints
(
checkpoints
=
checkpoints
,
user
=
attempt
.
user
,
status
=
status_to_set
)
lms/djangoapps/verify_student/migrations/0013_auto__add_field_softwaresecurephotoverification_copy_id_photo_from.py
0 → 100644
View file @
8afb3605
This diff is collapsed.
Click to expand it.
lms/djangoapps/verify_student/migrations/0014_set_copy_id_photo_from.py
0 → 100644
View file @
8afb3605
This diff is collapsed.
Click to expand it.
lms/djangoapps/verify_student/models.py
View file @
8afb3605
...
...
@@ -588,16 +588,23 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
photo_id_key
=
models
.
TextField
(
max_length
=
1024
)
IMAGE_LINK_DURATION
=
5
*
60
*
60
*
24
# 5 days in seconds
copy_id_photo_from
=
models
.
ForeignKey
(
"self"
,
null
=
True
,
blank
=
True
)
@classmethod
def
get_initial_verification
(
cls
,
user
):
"""Get initial verification for a user
"""Get initial verification for a user with the 'photo_id_key'.
Arguments:
user(User): user object
Return:
SoftwareSecurePhotoVerification (object)
"""
init_verification
=
cls
.
objects
.
filter
(
user
=
user
,
status__in
=
[
"submitted"
,
"approved"
])
init_verification
=
cls
.
objects
.
filter
(
user
=
user
,
status__in
=
[
"submitted"
,
"approved"
]
)
.
exclude
(
photo_id_key
=
''
)
return
init_verification
.
latest
(
'created_at'
)
if
init_verification
.
exists
()
else
None
@status_before_must_be
(
"created"
)
...
...
lms/djangoapps/verify_student/tests/test_models.py
View file @
8afb3605
...
...
@@ -472,6 +472,38 @@ class TestPhotoVerification(ModuleStoreTestCase):
status
=
SoftwareSecurePhotoVerification
.
verification_status_for_user
(
user
,
course
.
id
,
enrollment_mode
)
self
.
assertEqual
(
status
,
output
)
def
test_initial_verification_for_user
(
self
):
"""Test that method 'get_initial_verification' of model
'SoftwareSecurePhotoVerification' always returns the initial
verification with field 'photo_id_key' set against a user.
"""
user
=
UserFactory
.
create
()
# No initial verification for the user
result
=
SoftwareSecurePhotoVerification
.
get_initial_verification
(
user
=
user
)
self
.
assertIs
(
result
,
None
)
# Make an initial verification with 'photo_id_key'
attempt
=
SoftwareSecurePhotoVerification
(
user
=
user
,
photo_id_key
=
"dummy_photo_id_key"
)
attempt
.
status
=
'approved'
attempt
.
save
()
# Check that method 'get_initial_verification' returns the correct
# initial verification attempt
first_result
=
SoftwareSecurePhotoVerification
.
get_initial_verification
(
user
=
user
)
self
.
assertIsNotNone
(
first_result
)
# Now create a second verification without 'photo_id_key'
attempt
=
SoftwareSecurePhotoVerification
(
user
=
user
)
attempt
.
status
=
'submitted'
attempt
.
save
()
# Test method 'get_initial_verification' still returns the correct
# initial verification attempt which have 'photo_id_key' set
second_result
=
SoftwareSecurePhotoVerification
.
get_initial_verification
(
user
=
user
)
self
.
assertIsNotNone
(
second_result
)
self
.
assertEqual
(
second_result
,
first_result
)
@ddt.ddt
class
VerificationCheckpointTest
(
ModuleStoreTestCase
):
...
...
lms/djangoapps/verify_student/tests/test_views.py
View file @
8afb3605
...
...
@@ -1420,11 +1420,15 @@ class TestSubmitPhotosForVerification(TestCase):
"Photo ID image is required if the user does not have an initial verification attempt."
)
# Create the initial verification attempt
# Create the initial verification attempt with some dummy
# value set for field 'photo_id_key'
self
.
_submit_photos
(
face_image
=
self
.
IMAGE_DATA
,
photo_id_image
=
self
.
IMAGE_DATA
,
)
attempt
=
SoftwareSecurePhotoVerification
.
objects
.
get
(
user
=
self
.
user
)
attempt
.
photo_id_key
=
"dummy_photo_id_key"
attempt
.
save
()
# Now the request should succeed
self
.
_submit_photos
(
face_image
=
self
.
IMAGE_DATA
)
...
...
@@ -2039,7 +2043,7 @@ class TestInCourseReverifyView(ModuleStoreTestCase):
"""
Helper method for initial verification.
"""
attempt
=
SoftwareSecurePhotoVerification
(
user
=
self
.
user
)
attempt
=
SoftwareSecurePhotoVerification
(
user
=
self
.
user
,
photo_id_key
=
"dummy_photo_id_key"
)
attempt
.
mark_ready
()
attempt
.
save
()
attempt
.
submit
()
...
...
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