diff --git a/lms/djangoapps/verify_student/models.py b/lms/djangoapps/verify_student/models.py index 02a865d4f0..063a501096 100644 --- a/lms/djangoapps/verify_student/models.py +++ b/lms/djangoapps/verify_student/models.py @@ -398,10 +398,10 @@ class PhotoVerification(IDVerificationAttempt): they uploaded are good. Note that we don't actually do a submission anywhere yet. """ - # At any point prior to this, they can change their names via their - # student dashboard. But at this point, we lock the value into the - # attempt. - self.name = self.user.profile.name # pylint: disable=no-member + # If a name is not already set via the verified_name flow, + # pick up the profile name at this time. + if not self.name: + self.name = self.user.profile.name # pylint: disable=no-member self.status = self.STATUS.ready self.save() diff --git a/lms/djangoapps/verify_student/tests/test_models.py b/lms/djangoapps/verify_student/tests/test_models.py index 268b48bbc1..efc26788f7 100644 --- a/lms/djangoapps/verify_student/tests/test_models.py +++ b/lms/djangoapps/verify_student/tests/test_models.py @@ -185,6 +185,20 @@ class TestPhotoVerification(TestVerificationBase, MockS3BotoMixin, ModuleStoreTe assert 'Clyde ƴ' == attempt.name + def test_name_preset(self): + """ + If a name was set when creating the photo verification + (from name affirmation / verified name flow) it should not + be overwritten by the profile name + """ + user = UserFactory.create() + user.profile.name = "Profile" + + preset_attempt = SoftwareSecurePhotoVerification(user=user) + preset_attempt.name = "Preset" + preset_attempt.mark_ready() + assert "Preset" == preset_attempt.name + def test_submissions(self): """Test that we set our status correctly after a submission.""" # Basic case, things go well.