Commit 6773c5c2 by Calen Pennington

If a student requests a certificate, but their name has changed, mark that the…

If a student requests a certificate, but their name has changed, mark that the certificate must be regenerated
parent 83d29106
......@@ -49,8 +49,8 @@ def certificate_state_for_student(student, grade):
This returns a dictionary with a key for state, and other information. The state is one of the
following:
unavailable - A student is not elligible for a certificate.
requestable - A student is elligible to request a certificate
unavailable - A student is not eligible for a certificate.
requestable - A student is eligible to request a certificate
generating - A student has requested a certificate, but it is not generated yet.
downloadable - The certificate has been requested and is available for download.
......
......@@ -104,14 +104,32 @@ def generate_certificate(user, grade):
generated_certificate.enabled = True
if generated_certificate.graded_download_url and (generated_certificate.grade != grade):
log.critical("A graded certificate has been pre-generated with the grade of " + str(generated_certificate.grade) + " but requested with grade " + str(grade) + \
"! The download URL is " + str(generated_certificate.graded_download_url))
log.critical("A graded certificate has been pre-generated with the grade "
"of {gen_grade} but requested by user id {userid} with grade "
"{req_grade}! The download URLs were {graded_dl_url} and "
"{ungraded_dl_url}".format(
gen_grade=generated_certificate.grade,
req_grade=grade,
graded_dl_url=generated_certificate.graded_download_url,
ungraded_dl_url=generated_certificate.download_url,
userid=user.id))
generated_certificate.graded_download_url = None
generated_certificate.download_url = None
user_name = UserProfile.objects.get(user = user).name
if generated_certificate.download_url and (generated_certificate.name != user_name):
log.critical("A Certificate has been pre-generated with the name of " + str(generated_certificate.name) + " but current name is " + str(user_name) + \
"! The download URL is " + str(generated_certificate.download_url))
log.critical("A Certificate has been pre-generated with the name of "
"{gen_name} but current name is {user_name} (user id is "
"{userid})! The download URLs were {graded_dl_url} and "
"{ungraded_dl_url}".format(
gen_name=generated_certificate.name,
user_name=user_name.encode('utf-8'),
graded_dl_url=generated_certificate.graded_download_url,
ungraded_dl_url=generated_certificate.download_url,
userid=user.id))
generated_certificate.graded_download_url = None
generated_certificate.download_url = None
generated_certificate.grade = grade
generated_certificate.name = user_name
......
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