From 2d6a4126e74559564fcbf7f844193c2ceb9574fb Mon Sep 17 00:00:00 2001 From: Justin Hynes Date: Tue, 6 Apr 2021 08:06:27 -0400 Subject: [PATCH] fix: invalidate certificate properly when using regeneration from support tool [MICROBA-974] * Update `regen_cert` function to call the certificate objects `invalidate` method, instead of just setting the certificate status as 'unavailable'. This change will make it so the certificate revoked signal is sent in an attempt to keep data in the Credentials IDA in sync --- lms/djangoapps/certificates/queue.py | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/lms/djangoapps/certificates/queue.py b/lms/djangoapps/certificates/queue.py index d84ad71b8c..744f73382a 100644 --- a/lms/djangoapps/certificates/queue.py +++ b/lms/djangoapps/certificates/queue.py @@ -114,12 +114,12 @@ class XQueueCertInterface: student - User.object course_id - courseenrollment.course_id (string) + [PDF Certificates only] WARNING: this command will leave the old certificate, if one exists, laying around in AWS taking up space. If this is a problem, take pains to clean up storage before running this command. - Change the certificate status to unavailable (if it exists) and request - grading. Passing grades will put a certificate request on the queue. + Invalidate the certificate (if it exists) and request a new certificate. Return the certificate. """ @@ -131,14 +131,8 @@ class XQueueCertInterface: certificate = GeneratedCertificate.eligible_certificates.get(user=student, course_id=course_id) LOGGER.info( - ( - "Found an existing certificate entry for student %s " - "in course '%s' " - "with status '%s' while regenerating certificates. " - ), - student.id, - str(course_id), - certificate.status + f"Found an existing certificate entry for student {student.id} in course '{course_id}' with status " + f"'{certificate.status}' while regenerating certificates." ) if certificate.download_url: @@ -147,19 +141,12 @@ class XQueueCertInterface: ) return None - certificate.status = status.unavailable - certificate.save() + certificate.invalidate() LOGGER.info( - ( - "The certificate status for student %s " - "in course '%s' has been changed to '%s'." - ), - student.id, - str(course_id), - certificate.status + f"The certificate status for student {student.id} in course '{course_id} has been changed to " + f"'{certificate.status}'." ) - except GeneratedCertificate.DoesNotExist: pass