def format_certificate_for_user(username, cert):
 return {'username': username, 'course_key': cert.course_id, 'type': cert.mode, 'status': cert.status, 'grade': cert.grade, 'created': cert.created_date, 'modified': cert.modified_date, 'download_url': ((cert.download_url or get_certificate_url(cert.user.id, cert.course_id)) if (cert.status == CertificateStatuses.downloadable) else None)}

def format_certificate_for_user ( username , cert ) : return { 'username' : username , 'course_key' : cert . course_id , 'type' : cert . mode , 'status' : cert . status , 'grade' : cert . grade , 'created' : cert . created_date , 'modified' : cert . modified_date , 'download_url' : ( ( cert . download_url or get_certificate_url ( cert . user . id , cert . course_id ) ) if ( cert . status == CertificateStatuses . downloadable ) else None ) }
helper function to serialize an user certificate .