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


Python EmailTemplate.send_to_user方法代码示例

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


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

示例1: send_publish_notifications

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_user [as 别名]
def send_publish_notifications(courses, template=None):
    from evap.evaluation.models import EmailTemplate
    publish_notifications = defaultdict(set)

    if not template:
        template = EmailTemplate.objects.get(name=EmailTemplate.PUBLISHING_NOTICE)

    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)

            for contributor in course.responsible_contributors:
                publish_notifications[contributor].add(course)

    for user, course_set in publish_notifications.items():
        body_params = {'user': user, 'courses': list(course_set)}
        EmailTemplate.send_to_user(user, template, {}, body_params, use_cc=True)
开发者ID:JenniferStamm,项目名称:EvaP,代码行数:29,代码来源:tools.py

示例2: send

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_user [as 别名]
 def send(self, request, courses):
     recipient = self.cleaned_data.get('to')
     self.template.subject = self.cleaned_data.get('subject')
     self.template.body = self.cleaned_data.get('body')
     subject_params = {}
     body_params = {'user': recipient, 'courses': courses}
     EmailTemplate.send_to_user(recipient, self.template, subject_params, body_params, use_cc=True, request=request)
开发者ID:PFischbeck,项目名称:EvaP,代码行数:9,代码来源:forms.py

示例3: evaluation_direct_delegation

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_user [as 别名]
def evaluation_direct_delegation(request, evaluation_id):
    delegate_user_id = request.POST.get("delegate_to")

    evaluation = get_object_or_404(Evaluation, id=evaluation_id)
    delegate_user = get_object_or_404(UserProfile, id=delegate_user_id)

    contribution, created = Contribution.objects.update_or_create(evaluation=evaluation, contributor=delegate_user, defaults={'can_edit': True})
    if created:
        contribution.order = evaluation.contributions.all().aggregate(Max('order'))['order__max'] + 1
        contribution.save()

    template = EmailTemplate.objects.get(name=EmailTemplate.DIRECT_DELEGATION)
    subject_params = {"evaluation": evaluation, "user": request.user, "delegate_user": delegate_user}
    body_params = subject_params

    # we don't provide the request here since send_to_user only uses it to display a warning message in case the user does not have
    # an email address. In this special case, we don't want that warning. Instead, we want a mail to the admins.
    EmailTemplate.send_to_user(delegate_user, template, subject_params, body_params, use_cc=True, additional_cc_user=request.user)

    messages.add_message(
        request,
        messages.SUCCESS,
        _('{} was added as a contributor for evaluation "{}" and was sent an email with further information.').format(str(delegate_user), str(evaluation))
    )

    return redirect('contributor:index')
开发者ID:fsr-itse,项目名称:EvaP,代码行数:28,代码来源:views.py

示例4: send_publish_notifications

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_user [as 别名]
def send_publish_notifications(courses, template=None):
    from evap.evaluation.models import EmailTemplate
    publish_notifications = defaultdict(set)

    if not template:
        template = EmailTemplate.objects.get(name=EmailTemplate.PUBLISHING_NOTICE)

    for course in courses:
        # for courses with published averaged grade, all contributors and participants get a notification
        # we don't send a notification if the significance threshold isn't met
        if course.can_publish_average_grade:
            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 the average grade was not published, notifications are only sent for contributors who can see text answers
        elif course.textanswer_set:
            for textanswer in course.textanswer_set:
                if textanswer.contribution.contributor:
                    publish_notifications[textanswer.contribution.contributor].add(course)

            for contributor in course.responsible_contributors:
                publish_notifications[contributor].add(course)

    for user, course_set in publish_notifications.items():
        body_params = {'user': user, 'courses': list(course_set)}
        EmailTemplate.send_to_user(user, template, {}, body_params, use_cc=True)
开发者ID:PFischbeck,项目名称:EvaP,代码行数:30,代码来源:tools.py

示例5: send_publish_notifications

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_user [as 别名]
def send_publish_notifications(evaluations, template_contributor=USE_DEFAULT, template_participant=USE_DEFAULT):
    from evap.evaluation.models import EmailTemplate

    if template_contributor == USE_DEFAULT:
        template_contributor = EmailTemplate.objects.get(name=EmailTemplate.PUBLISHING_NOTICE_CONTRIBUTOR)

    if template_participant == USE_DEFAULT:
        template_participant = EmailTemplate.objects.get(name=EmailTemplate.PUBLISHING_NOTICE_PARTICIPANT)

    evaluations_for_contributors = defaultdict(set)
    evaluations_for_participants = defaultdict(set)

    for evaluation in evaluations:
        # for evaluations with published averaged grade, all contributors and participants get a notification
        # we don't send a notification if the significance threshold isn't met
        if evaluation.can_publish_average_grade:
            if template_contributor:
                for contribution in evaluation.contributions.all():
                    if contribution.contributor:
                        evaluations_for_contributors[contribution.contributor].add(evaluation)

            if template_participant:
                for participant in evaluation.participants.all():
                    evaluations_for_participants[participant].add(evaluation)

        # if the average grade was not published, notifications are only sent for contributors who can see text answers
        elif evaluation.textanswer_set and template_contributor:
            for textanswer in evaluation.textanswer_set:
                if textanswer.contribution.contributor:
                    evaluations_for_contributors[textanswer.contribution.contributor].add(evaluation)

            for contributor in evaluation.course.responsibles.all():
                evaluations_for_contributors[contributor].add(evaluation)

    assert(not evaluations_for_contributors or template_contributor)
    assert(not evaluations_for_participants or template_participant)

    for contributor, evaluation_set in evaluations_for_contributors.items():
        body_params = {'user': contributor, 'evaluations': list(evaluation_set)}
        EmailTemplate.send_to_user(contributor, template_contributor, {}, body_params, use_cc=True)

    for participant, evaluation_set in evaluations_for_participants.items():
        body_params = {'user': participant, 'evaluations': list(evaluation_set)}
        EmailTemplate.send_to_user(participant, template_participant, {}, body_params, use_cc=True)
开发者ID:fsr-itse,项目名称:EvaP,代码行数:46,代码来源:tools.py


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