MICROBA-918 Unify course cert invalidation (#26691)

This commit is contained in:
Christie Rice
2021-02-25 10:30:18 -05:00
committed by GitHub
parent 1938ccda71
commit fdc219a319
2 changed files with 10 additions and 9 deletions

View File

@@ -407,6 +407,13 @@ class GeneratedCertificate(models.Model):
self.grade = grade
self.status = CertificateStatuses.notpassing
self.save()
COURSE_CERT_REVOKED.send_robust(
sender=self.__class__,
user=self.user,
course_key=self.course_id,
mode=self.mode,
status=self.status,
)
def is_valid(self):
"""

View File

@@ -155,18 +155,12 @@ def _invalidate_generated_certificates(course_id, enrolled_students, certificate
allowlisted_users = get_allowlisted_users(course_id)
# Mark generated certificates as 'unavailable' and update download_url, download_uui, verify_uuid and
# grade with empty string for each cert that is not allowlisted. We loop over the certs and save each individually
# in order to save a history of the change.
# Invalidate each cert that is not allowlisted. We loop over the certs and invalidate each individually in order to
# save a history of the change.
for c in certificates:
if c.user in allowlisted_users:
log.info(f'Certificate for user {c.user.id} will not be invalidated because they are on the allowlist for '
f'course {course_id}')
else:
log.info(f'About to invalidate certificate for user {c.user.id} in course {course_id}')
c.status = CertificateStatuses.unavailable
c.verify_uuid = ''
c.download_uuid = ''
c.download_url = ''
c.grade = ''
c.save()
c.invalidate()