Commit f6d7cc55 by John Jarvis

save the cert record immediately after we set the status

There was a potential though unlikely race condition because the .save()
was after the certificate request was put on the queue.

Now calling .save() immediately after we update the
cert.
parent 18c1bcdf
...@@ -194,6 +194,7 @@ class XQueueCertInterface(object): ...@@ -194,6 +194,7 @@ class XQueueCertInterface(object):
# on the queue # on the queue
if self.restricted.filter(user=student).exists(): if self.restricted.filter(user=student).exists():
cert.status = status.restricted cert.status = status.restricted
cert.save()
else: else:
contents = { contents = {
'action': 'create', 'action': 'create',
...@@ -202,15 +203,15 @@ class XQueueCertInterface(object): ...@@ -202,15 +203,15 @@ class XQueueCertInterface(object):
'name': profile.name, 'name': profile.name,
} }
cert.status = status.generating cert.status = status.generating
self._send_to_xqueue(contents, key)
cert.save() cert.save()
self._send_to_xqueue(contents, key)
else: else:
cert_status = status.notpassing cert_status = status.notpassing
cert.grade = grade['percent'] cert.grade = grade['percent']
cert.status = cert_status
cert.user = student cert.user = student
cert.course_id = course_id cert.course_id = course_id
cert.name = profile.name cert.name = profile.name
cert.status = cert_status
cert.save() cert.save()
return cert_status return cert_status
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment