Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add VerificationAttempt model to IDVerificationService logic #35311

Merged
merged 4 commits into from
Sep 11, 2024

Conversation

zacharis278
Copy link
Contributor

Description

The new VerificationAttempt model (#35304) will now be taken into account when determining a user's verification status.

Supporting information

Please see openedx/platform-roadmap#367 and [Proposal] Add Extensibility Mechanisms to IDV to Enable Integration of New IDV Vendor Persona for more details.

@@ -244,6 +253,9 @@ def get_verification_details_by_id(cls, attempt_id):
If the verification object cannot be found, returns None
"""
verification = None

# TODO: Not updated for new model since we can't query multiple tables
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we consider this function out of scope for this ticket? We can't refactor or remove it until we change how the support tools work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me, especially given that this is dependent on changes elsewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, yes. However, it's possible Axim may not approve this without us either fixing it or describing our plan to fix it in detail, so let's see how our conversation goes tomorrow and go from there. I think there's no harm putting it up for review - we could get some additional feedback about how we could solve this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Update] We've decided to move ahead with this PR. I've left a comment on this function detailing that it has not been updated to account for the new model and referenced the DEPR here: #35452

@zacharis278 zacharis278 changed the title feat: Add VerificationAttempt model to IDV logic feat: Add VerificationAttempt model to IDVerificationService logic Aug 13, 2024
Copy link
Contributor

@MichaelRoytman MichaelRoytman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me - left a few quick thoughts.

VerificationAttempt.objects.filter(**{
'user__in': users,
'status': 'approved',
'created__gt': now() - timedelta(days=settings.VERIFY_STUDENT["DAYS_GOOD_FOR"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, is this because TimestampedModel changed the name of created_at to created at some point? 🤦‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually not even a timestamped model. There are explicit fields for created_at and updated_at instead of created/modified. Unfortunately I can't just use a model property here since this is a query.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. I'm tempted to just name the fields created_at and updated_at in the generic model, but I think using TimestampedModel is a better approach longer term.

lms/djangoapps/verify_student/models.py Outdated Show resolved Hide resolved
@@ -244,6 +253,9 @@ def get_verification_details_by_id(cls, attempt_id):
If the verification object cannot be found, returns None
"""
verification = None

# TODO: Not updated for new model since we can't query multiple tables
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, yes. However, it's possible Axim may not approve this without us either fixing it or describing our plan to fix it in detail, so let's see how our conversation goes tomorrow and go from there. I think there's no harm putting it up for review - we could get some additional feedback about how we could solve this.

Copy link
Member

@varshamenon4 varshamenon4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far! Just a couple of questions and suggestions. :)

@@ -75,7 +75,8 @@ def verifications_for_user(cls, user):
Return a list of all verifications associated with the given user.
"""
verifications = []
for verification in chain(SoftwareSecurePhotoVerification.objects.filter(user=user).order_by('-created_at'),
for verification in chain(VerificationAttempt.objects.filter(user=user).order_by('-created'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 'created_at'? Does it matter if it's not matching others?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to the old models not inheriting from TimestampedModel

@@ -117,11 +123,14 @@ def get_expiration_datetime(cls, user, statuses):
'status__in': statuses,
}

id_verifications = VerificationAttempt.objects.filter(**filter_kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be something in front of id_verifications here to specify what kind of id verification this is? Is persona_id_verifications too specific here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this is intended to be the most general verification model so it doesn't need further specification

@@ -244,6 +253,9 @@ def get_verification_details_by_id(cls, attempt_id):
If the verification object cannot be found, returns None
"""
verification = None

# TODO: Not updated for new model since we can't query multiple tables
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me, especially given that this is dependent on changes elsewhere?

@@ -34,12 +40,15 @@ class TestIDVerificationService(ModuleStoreTestCase):
Tests for IDVerificationService.
"""

def test_user_is_verified(self):
@ddt.data(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@MichaelRoytman MichaelRoytman force-pushed the michaelroytman/COSMO-421-VerificationAttempt-model branch from 844e1a4 to f734bde Compare August 14, 2024 14:09
@MichaelRoytman MichaelRoytman force-pushed the michaelroytman/COSMO-421-VerificationAttempt-model branch 2 times, most recently from 5a49c5d to b30318a Compare August 26, 2024 14:54
Base automatically changed from michaelroytman/COSMO-421-VerificationAttempt-model to master August 26, 2024 17:37
@zacharis278 zacharis278 force-pushed the zhancock/generic-verification branch from 3035ba7 to f7ddb7d Compare September 9, 2024 20:20
@zacharis278 zacharis278 marked this pull request as ready for review September 10, 2024 13:29
Copy link
Contributor

@schenedx schenedx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@zacharis278 zacharis278 merged commit d59e2f4 into master Sep 11, 2024
49 checks passed
@zacharis278 zacharis278 deleted the zhancock/generic-verification branch September 11, 2024 14:30
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants