当前位置: 首页>>代码示例>>Python>>正文


Python EmailTemplate.get_publish_template方法代码示例

本文整理汇总了Python中evap.evaluation.models.EmailTemplate.get_publish_template方法的典型用法代码示例。如果您正苦于以下问题:Python EmailTemplate.get_publish_template方法的具体用法?Python EmailTemplate.get_publish_template怎么用?Python EmailTemplate.get_publish_template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在evap.evaluation.models.EmailTemplate的用法示例。


在下文中一共展示了EmailTemplate.get_publish_template方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: semester_publish

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import get_publish_template [as 别名]
def semester_publish(request, semester_id):
    semester = get_object_or_404(Semester, id=semester_id)
    courses = semester.course_set.filter(state="reviewed").all()

    forms = helper_create_grouped_course_selection_forms(courses, None, request)

    valid = helper_are_course_selection_forms_valid(forms)

    for form in forms:
        for course_id, field in form.fields.items():
            course = Course.objects.get(pk=course_id)
            field.label += " (graded)" if course.is_graded else " (not graded)" 

    if valid:
        selected_courses = []
        for form in forms:
            for course in form.selected_courses:
                course.publish()
                course.save()
                selected_courses.append(course)
        messages.success(request, _("Successfully published %d courses.") % (len(selected_courses)))

        for user, courses in user_publish_notifications(selected_courses).iteritems():
            try:
                EmailTemplate.get_publish_template().send_to_user(user, courses=list(courses))
            except Exception:
                messages.error(request, _("Could not send notification email to ") + user.username)
        
        return redirect('evap.staff.views.semester_view', semester_id)
    else:
        return render(request, "staff_semester_publish.html", dict(semester=semester, forms=forms))
开发者ID:janno42,项目名称:EvaP,代码行数:33,代码来源:views.py

示例2: semester_publish

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import get_publish_template [as 别名]
def semester_publish(request, semester_id):
    semester = get_object_or_404(Semester, id=semester_id)
    courses = semester.course_set.filter(state="reviewed").all()

    forms = helper_create_grouped_course_selection_forms(courses, None, request)

    valid = helper_are_course_selection_forms_valid(forms)

    if valid:
        selected_courses = []
        for form in forms:
            for course in form.selected_courses:
                course.publish()
                course.save()
                selected_courses.append(course)

        try:
            EmailTemplate.get_publish_template().send_to_users_in_courses(selected_courses, ['contributors', 'all_participants'])
        except Exception:
            messages.error(request, _("Could not send emails to participants and contributors"))
        messages.success(request, _("Successfully published %d courses.") % (len(selected_courses)))
        return redirect('evap.fsr.views.semester_view', semester_id)
    else:
        return render_to_response("fsr_semester_publish.html", dict(semester=semester, forms=forms), context_instance=RequestContext(request))
开发者ID:Nef10,项目名称:EvaP,代码行数:26,代码来源:views.py


注:本文中的evap.evaluation.models.EmailTemplate.get_publish_template方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。