feat: add parameter to submit attempt to carry full name through

original behavior does pass the empty name through to
_update_full_name rather than just considering that as full name not
set. That's a little weird but outside the scope of this work so I've
preserved it by checking is not None rather than just using full_name
as a boolean.

MST-1015
This commit is contained in:
Andy Shultz
2021-09-08 13:46:44 -04:00
parent 695f2cd4c8
commit dc01bf3aad
2 changed files with 15 additions and 4 deletions

View File

@@ -1269,6 +1269,10 @@ class TestSubmitPhotosForVerification(MockS3BotoMixin, TestVerificationBase):
# Check that the user's name was changed in the database if verified_name is off
self._assert_user_name(self.FULL_NAME, equality=not flag_on)
# Since we are giving a full name, it should be written into the attempt
# whether or not the user name was updated
attempt = SoftwareSecurePhotoVerification.objects.get(user=self.user)
self.assertEqual(attempt.name, self.FULL_NAME)
def test_submit_photos_sends_confirmation_email(self):
self._submit_photos(

View File

@@ -846,9 +846,13 @@ class SubmitPhotosView(View):
if response is not None:
return response
full_name = None
if "full_name" in params:
full_name = params["full_name"]
# If necessary, update the user's full name
if "full_name" in params and not is_verified_name_enabled():
response = self._update_full_name(request, params["full_name"])
if full_name is not None and not is_verified_name_enabled():
response = self._update_full_name(request, full_name)
if response is not None:
return response
@@ -867,7 +871,7 @@ class SubmitPhotosView(View):
return response
# Submit the attempt
attempt = self._submit_attempt(request.user, face_image, photo_id_image, initial_verification)
attempt = self._submit_attempt(request.user, face_image, photo_id_image, initial_verification, full_name)
# Send event to segment for analyzing A/B testing data
data = {
@@ -1019,7 +1023,7 @@ class SubmitPhotosView(View):
log.error(("Image data for user {user_id} is not valid").format(user_id=request.user.id))
return None, None, HttpResponseBadRequest(msg)
def _submit_attempt(self, user, face_image, photo_id_image=None, initial_verification=None):
def _submit_attempt(self, user, face_image, photo_id_image=None, initial_verification=None, provided_name=None):
"""
Submit a verification attempt.
@@ -1030,8 +1034,11 @@ class SubmitPhotosView(View):
Keyword Arguments:
photo_id_image (str or None): Decoded photo ID image data.
initial_verification (SoftwareSecurePhotoVerification): The initial verification attempt.
provided_name (str or None): full name given by user for this attempt
"""
attempt = SoftwareSecurePhotoVerification(user=user)
if provided_name:
attempt.name = provided_name
# We will always have face image data, so upload the face image
attempt.upload_face_image(face_image)