'Dry method to generate certificate.'

def generate_certificate(self, url, mode):

    generated_certificate = GeneratedCertificateFactory.create(user=self.user, course_id=self.course.id, status=CertificateStatuses.downloadable, download_url=url, mode=mode)
    CertificateGenerationConfiguration(enabled=True).save()
    certs_api.set_cert_generation_enabled(self.course.id, True)
    return generated_certificate
