'(Re-)Make certificate for a particular student in a particular course
Arguments:
student   - User.object
course_id - courseenrollment.course_id (string)
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.
Return the certificate.'

def regen_cert(self, student, course_id, course=None, forced_grade=None, template_file=None, generate_pdf=True):

    try:
        certificate = GeneratedCertificate.eligible_certificates.get(user=student, course_id=course_id)
        LOGGER.info(u"Found    an    existing    certificate    entry    for    student    %s    in    course    '%s'    with    status    '%s'    while    regenerating    certificates.    ", student.id, unicode(course_id), certificate.status)
        certificate.status = status.unavailable
        certificate.save()
        LOGGER.info(u"The    certificate    status    for    student    %s    in    course    '%s'    has    been    changed    to    '%s'.", student.id, unicode(course_id), certificate.status)
    except GeneratedCertificate.DoesNotExist:
        pass
    return self.add_cert(student, course_id, course=course, forced_grade=forced_grade, template_file=template_file, generate_pdf=generate_pdf)
