Skip to content
Snippets Groups Projects
Unverified Commit fdc219a3 authored by Christie Rice's avatar Christie Rice Committed by GitHub
Browse files

MICROBA-918 Unify course cert invalidation (#26691)

parent 1938ccda
No related branches found
Tags release-2021-02-25-12.23
No related merge requests found
......@@ -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):
"""
......
......@@ -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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment