diff --git a/lms/djangoapps/verify_student/models.py b/lms/djangoapps/verify_student/models.py index a57221c683..5282f23025 100644 --- a/lms/djangoapps/verify_student/models.py +++ b/lms/djangoapps/verify_student/models.py @@ -33,6 +33,7 @@ from django.utils.translation import ugettext_lazy from model_utils import Choices from model_utils.models import StatusModel, TimeStampedModel from opaque_keys.edx.django.models import CourseKeyField +from openedx.core.djangolib.model_mixins import DeletableByUserValue from lms.djangoapps.verify_student.ssencrypt import ( encrypt_and_encode, @@ -235,7 +236,7 @@ class SSOVerification(IDVerificationAttempt): models.signals.post_save.connect(post_save_id_verification, sender=SSOVerification) -class PhotoVerification(IDVerificationAttempt): +class PhotoVerification(IDVerificationAttempt, DeletableByUserValue): """ Each PhotoVerification represents a Student's attempt to establish their identity by uploading a photo of themselves and a picture ID. An diff --git a/lms/djangoapps/verify_student/tests/test_models.py b/lms/djangoapps/verify_student/tests/test_models.py index 26e65f54f9..c7a52dfca7 100644 --- a/lms/djangoapps/verify_student/tests/test_models.py +++ b/lms/djangoapps/verify_student/tests/test_models.py @@ -330,6 +330,27 @@ class TestPhotoVerification(TestVerification, MockS3Mixin, ModuleStoreTestCase): self.assertIsNotNone(fourth_result) self.assertEqual(fourth_result, first_result) + def test_retire_user(self): + user = UserFactory.create() + user.profile.name = u"Enrique" + + attempt = SoftwareSecurePhotoVerification(user=user) + 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.approve() + + # Before Delete + 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') + + # Attempt + self.assertTrue(SoftwareSecurePhotoVerification.delete_by_user_value(user, "user")) + # Reattempt + self.assertFalse(SoftwareSecurePhotoVerification.delete_by_user_value(user, "user")) + class SSOVerificationTest(TestVerification): """