本文整理汇总了Python中evap.evaluation.models.EmailTemplate.send_publish_notifications_to_user方法的典型用法代码示例。如果您正苦于以下问题:Python EmailTemplate.send_publish_notifications_to_user方法的具体用法?Python EmailTemplate.send_publish_notifications_to_user怎么用?Python EmailTemplate.send_publish_notifications_to_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类evap.evaluation.models.EmailTemplate
的用法示例。
在下文中一共展示了EmailTemplate.send_publish_notifications_to_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_publish_notifications
# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_publish_notifications_to_user [as 别名]
def send_publish_notifications(grade_document_courses=None, evaluation_results_courses=None):
grade_document_courses = grade_document_courses or []
evaluation_results_courses = evaluation_results_courses or []
publish_notifications = defaultdict(lambda: CourseLists(set(), set()))
for course in evaluation_results_courses:
# for published courses all contributors and participants get a notification
if course.can_publish_grades:
for participant in course.participants.all():
publish_notifications[participant].evaluation_results_courses.add(course)
for contribution in course.contributions.all():
if contribution.contributor:
publish_notifications[contribution.contributor].evaluation_results_courses.add(course)
# if a course was not published notifications are only sent for contributors who can see comments
elif len(course.textanswer_set) > 0:
for textanswer in course.textanswer_set:
if textanswer.contribution.contributor:
publish_notifications[textanswer.contribution.contributor].evaluation_results_courses.add(course)
publish_notifications[course.responsible_contributor].evaluation_results_courses.add(course)
for course in grade_document_courses:
# all participants who can download grades get a notification
for participant in course.participants.all():
if participant.can_download_grades:
publish_notifications[participant].grade_document_courses.add(course)
for user, course_lists in publish_notifications.items():
EmailTemplate.send_publish_notifications_to_user(
user,
grade_document_courses=list(course_lists.grade_document_courses),
evaluation_results_courses=list(course_lists.evaluation_results_courses)
)
示例2: send_publish_notifications
# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_publish_notifications_to_user [as 别名]
def send_publish_notifications(courses):
publish_notifications = defaultdict(set)
for course in courses:
# for published courses all contributors and participants get a notification
if course.can_publish_grades:
for participant in course.participants.all():
publish_notifications[participant].add(course)
for contribution in course.contributions.all():
if contribution.contributor:
publish_notifications[contribution.contributor].add(course)
# if a course was not published notifications are only sent for contributors who can see comments
elif len(course.textanswer_set) > 0:
for textanswer in course.textanswer_set:
if textanswer.contribution.contributor:
publish_notifications[textanswer.contribution.contributor].add(course)
publish_notifications[course.responsible_contributor].add(course)
for user, course_set in publish_notifications.items():
EmailTemplate.send_publish_notifications_to_user(user, list(course_set))