From 265411770061b4507c98b3ecf464fbc26d9ed468 Mon Sep 17 00:00:00 2001 From: ilee2u Date: Thu, 26 Sep 2024 14:18:01 -0400 Subject: [PATCH] fix: revamp status_changed for back-compat --- lms/djangoapps/verify_student/api.py | 2 +- lms/djangoapps/verify_student/models.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/verify_student/api.py b/lms/djangoapps/verify_student/api.py index 7b8310fde030..94bd41442164 100644 --- a/lms/djangoapps/verify_student/api.py +++ b/lms/djangoapps/verify_student/api.py @@ -136,7 +136,7 @@ def update_verification_attempt( 'Status must be one of: %(status_list)s', { 'status': status, - 'status_list': VerificationAttempt.STATUS, + 'status_list': VerificationAttempt.STATUS_CHOICES, }, ) raise VerificationAttemptInvalidStatus diff --git a/lms/djangoapps/verify_student/models.py b/lms/djangoapps/verify_student/models.py index 4134d0aac0e5..73a02738d63b 100644 --- a/lms/djangoapps/verify_student/models.py +++ b/lms/djangoapps/verify_student/models.py @@ -1224,12 +1224,14 @@ class VerificationAttempt(TimeStampedModel, StatusModel): user = models.ForeignKey(User, db_index=True, on_delete=models.CASCADE) name = models.CharField(blank=True, max_length=255) - STATUS = Choices( - # VerificationAttemptStatus.CREATED, + STATUS_CHOICES = [ + VerificationAttemptStatus.CREATED, VerificationAttemptStatus.PENDING, VerificationAttemptStatus.APPROVED, VerificationAttemptStatus.DENIED, - ) + ] + + status = models.CharField(max_length=64, choices=[(status, status) for status in STATUS_CHOICES]) expiration_datetime = models.DateTimeField( null=True, @@ -1245,6 +1247,11 @@ def should_display_status_to_user(self): """When called, returns true or false based on the type of VerificationAttempt""" return not self.hide_status_from_user + @property + def status_changed(self): + """Backwards compatibility with existing IDVerification models""" + return self.modified + @property def updated_at(self): """Backwards compatibility with existing IDVerification models"""