def _get_user_certificate(request, user, course_key, course, preview_mode=None):
 user_certificate = None
 if preview_mode:
  if (has_access(request.user, 'instructor', course) or has_access(request.user, 'staff', course)):
   user_certificate = GeneratedCertificate(mode=preview_mode, verify_uuid=unicode(uuid4().hex), modified_date=datetime.now().date())
 else:
  try:
   user_certificate = GeneratedCertificate.eligible_certificates.get(user=user, course_id=course_key, status=CertificateStatuses.downloadable)
  except GeneratedCertificate.DoesNotExist:
   pass
 return user_certificate

def _get_user_certificate ( request , user , course_key , course , preview_mode = None ) : user_certificate = None if preview_mode : if ( has_access ( request . user , 'instructor' , course ) or has_access ( request . user , 'staff' , course ) ) : user_certificate = GeneratedCertificate ( mode = preview_mode , verify_uuid = unicode ( uuid4 ( ) . hex ) , modified_date = datetime . now ( ) . date ( ) ) else : try : user_certificate = GeneratedCertificate . eligible_certificates . get ( user = user , course_id = course_key , status = CertificateStatuses . downloadable ) except GeneratedCertificate . DoesNotExist : pass return user_certificate
retrieves users certificate from db .