本文整理汇总了Python中certificates.models.CertificateGenerationConfiguration.save方法的典型用法代码示例。如果您正苦于以下问题:Python CertificateGenerationConfiguration.save方法的具体用法?Python CertificateGenerationConfiguration.save怎么用?Python CertificateGenerationConfiguration.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类certificates.models.CertificateGenerationConfiguration
的用法示例。
在下文中一共展示了CertificateGenerationConfiguration.save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enable_auto_certificate_generation
# 需要导入模块: from certificates.models import CertificateGenerationConfiguration [as 别名]
# 或者: from certificates.models.CertificateGenerationConfiguration import save [as 别名]
def enable_auto_certificate_generation(apps, schema_editor):
""" add an enabled CertificateGenerationConfiguration and
enable student-generated certificates on all courses
by setting the enabled bit
"""
# not sure why I'm not getting the certificates app, so we'll force it
from certificates.models import CertificateGenerationConfiguration, CertificateGenerationCourseSetting
apps.load_app('certificates')
apps.register_models('certificates', CertificateGenerationConfiguration)
apps.register_models('certificates', CertificateGenerationCourseSetting)
CertificateGenerationConfiguration = apps.get_model("certificates", "CertificateGenerationConfiguration")
ccg = CertificateGenerationConfiguration(enabled=1) # configuration model. just add a new one
ccg.save()
CertificateGenerationCourseSetting = apps.get_model("certificates", "CertificateGenerationCourseSetting")
courses = modulestore().get_courses()
for course in courses:
key = course.location.course_key
ccs, created = CertificateGenerationCourseSetting.objects.get_or_create(course_key=key, enabled=1)
if not created:
ccs.enabled = 1
ccs.save()