def add_verification_status(self, user, status): """Adding the verification status for a user.""" VerificationStatus.add_status_from_checkpoints( checkpoints=[self.first_checkpoint], user=user, status=status )
def test_add_status_from_checkpoints(self, status): """Test verification status for reverification checkpoints after submitting software secure photo verification. """ # add initial verification status for checkpoints initial_status = "submitted" VerificationStatus.add_verification_status( checkpoint=self.first_checkpoint, user=self.user, status=initial_status) VerificationStatus.add_verification_status( checkpoint=self.second_checkpoint, user=self.user, status=initial_status) # now add verification status for multiple checkpoint points VerificationStatus.add_status_from_checkpoints( checkpoints=[self.first_checkpoint, self.second_checkpoint], user=self.user, status=status) # test that verification status entries with new status have been added # for both checkpoints result = VerificationStatus.objects.filter( user=self.user, checkpoint=self.first_checkpoint) self.assertEqual(len(result), len(self.first_checkpoint.checkpoint_status.all())) self.assertEqual( list( result.values_list('checkpoint__checkpoint_location', flat=True)), list( self.first_checkpoint.checkpoint_status.values_list( 'checkpoint__checkpoint_location', flat=True))) result = VerificationStatus.objects.filter( user=self.user, checkpoint=self.second_checkpoint) self.assertEqual(len(result), len(self.second_checkpoint.checkpoint_status.all())) self.assertEqual( list( result.values_list('checkpoint__checkpoint_location', flat=True)), list( self.second_checkpoint.checkpoint_status.values_list( 'checkpoint__checkpoint_location', flat=True)))
def handle(self, *args, **kwargs): # pylint: disable=unused-argument from lms.djangoapps.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)
def handle(self, *args, **kwargs): # pylint: disable=unused-argument from lms.djangoapps.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 )
def test_add_status_from_checkpoints(self, status): """Test verification status for reverification checkpoints after submitting software secure photo verification. """ # add initial verification status for checkpoints initial_status = "submitted" VerificationStatus.add_verification_status( checkpoint=self.first_checkpoint, user=self.user, status=initial_status ) VerificationStatus.add_verification_status( checkpoint=self.second_checkpoint, user=self.user, status=initial_status ) # now add verification status for multiple checkpoint points VerificationStatus.add_status_from_checkpoints( checkpoints=[self.first_checkpoint, self.second_checkpoint], user=self.user, status=status ) # test that verification status entries with new status have been added # for both checkpoints result = VerificationStatus.objects.filter(user=self.user, checkpoint=self.first_checkpoint) self.assertEqual(len(result), len(self.first_checkpoint.checkpoint_status.all())) self.assertEqual( list(result.values_list('checkpoint__checkpoint_location', flat=True)), list(self.first_checkpoint.checkpoint_status.values_list('checkpoint__checkpoint_location', flat=True)) ) result = VerificationStatus.objects.filter(user=self.user, checkpoint=self.second_checkpoint) self.assertEqual(len(result), len(self.second_checkpoint.checkpoint_status.all())) self.assertEqual( list(result.values_list('checkpoint__checkpoint_location', flat=True)), list(self.second_checkpoint.checkpoint_status.values_list('checkpoint__checkpoint_location', flat=True)) )