Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
75f94f97
Unverified
Commit
75f94f97
authored
6 years ago
by
Gregory Martin
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #18079 from edx/yro/EDUCATOR-2700-B
Update models to 'Retire' not delete data
parents
507100b7
16a5555c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/verify_student/models.py
+25
-1
25 additions, 1 deletion
lms/djangoapps/verify_student/models.py
lms/djangoapps/verify_student/tests/test_models.py
+30
-6
30 additions, 6 deletions
lms/djangoapps/verify_student/tests/test_models.py
with
55 additions
and
7 deletions
lms/djangoapps/verify_student/models.py
+
25
−
1
View file @
75f94f97
...
...
@@ -189,7 +189,7 @@ class SSOVerification(IDVerificationAttempt):
)
class
PhotoVerification
(
IDVerificationAttempt
,
DeletableByUserValue
):
class
PhotoVerification
(
IDVerificationAttempt
):
"""
Each PhotoVerification represents a Student
'
s attempt to establish
their identity by uploading a photo of themselves and a picture ID. An
...
...
@@ -464,6 +464,30 @@ class PhotoVerification(IDVerificationAttempt, DeletableByUserValue):
self
.
status
=
"
must_retry
"
self
.
save
()
@classmethod
def
retire_user
(
cls
,
user_id
):
"""
Retire user as part of GDPR Phase I
Returns
'
True
'
if records found
:param user_id: int
:return: bool
"""
try
:
user_obj
=
User
.
objects
.
get
(
id
=
user_id
)
except
User
.
DoesNotExist
:
return
False
photo_objects
=
cls
.
objects
.
filter
(
user
=
user_obj
).
update
(
name
=
''
,
face_image_url
=
''
,
photo_id_image_url
=
''
,
photo_id_key
=
''
)
return
photo_objects
>
0
class
SoftwareSecurePhotoVerification
(
PhotoVerification
):
"""
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/verify_student/tests/test_models.py
+
30
−
6
View file @
75f94f97
...
...
@@ -319,25 +319,49 @@ class TestPhotoVerification(MockS3Mixin, ModuleStoreTestCase):
self
.
assertEqual
(
fourth_result
,
first_result
)
def
test_retire_user
(
self
):
"""
Retire user with record(s) in table
"""
user
=
UserFactory
.
create
()
user
.
profile
.
name
=
u
"
Enrique
"
attempt
=
SoftwareSecurePhotoVerification
(
user
=
user
)
# Populate Record
attempt
.
mark_ready
()
attempt
.
status
=
"
submitted
"
attempt
.
photo_id_image_url
=
"
https://example.com/test/image/img.jpg
"
attempt
.
face_image_url
=
"
https://example.com/test/face/img.jpg
"
attempt
.
photo_id_key
=
'
there_was_an_attempt
'
attempt
.
approve
()
#
Before Delete
#
Validate data before retirement
assert_equals
(
attempt
.
name
,
user
.
profile
.
name
)
assert_equals
(
attempt
.
photo_id_image_url
,
'
https://example.com/test/image/img.jpg
'
)
assert_equals
(
attempt
.
face_image_url
,
'
https://example.com/test/face/img.jpg
'
)
assert_equals
(
attempt
.
photo_id_key
,
'
there_was_an_attempt
'
)
# Retire User
attempt_again
=
SoftwareSecurePhotoVerification
(
user
=
user
)
self
.
assertTrue
(
attempt_again
.
retire_user
(
user_id
=
user
.
id
))
# Validate data after retirement
self
.
assertEqual
(
attempt_again
.
name
,
''
)
self
.
assertEqual
(
attempt_again
.
face_image_url
,
''
)
self
.
assertEqual
(
attempt_again
.
photo_id_image_url
,
''
)
self
.
assertEqual
(
attempt_again
.
photo_id_key
,
''
)
def
test_retire_nonuser
(
self
):
"""
Attempt to Retire User with no records in table
"""
user
=
UserFactory
.
create
()
attempt
=
SoftwareSecurePhotoVerification
(
user
=
user
)
# User with no records in table
self
.
assertFalse
(
attempt
.
retire_user
(
user_id
=
user
.
id
))
# Attempt
self
.
assertTrue
(
SoftwareSecurePhotoVerification
.
delete_by_user_value
(
user
,
"
user
"
))
# Reattempt
self
.
assertFalse
(
SoftwareSecurePhotoVerification
.
delete_by_user_value
(
user
,
"
user
"
))
# No user
self
.
assertFalse
(
attempt
.
retire_user
(
user_id
=
47
))
class
VerificationDeadlineTest
(
CacheIsolationTestCase
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment