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


Python EmailTemplate.send_to_users_in_courses方法代码示例

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


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

示例1: CourseEmailForm

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_users_in_courses [as 别名]
class CourseEmailForm(forms.Form, BootstrapMixin):
    recipients = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple(), choices=EMAIL_RECIPIENTS, label=_("Send email to"))
    subject = forms.CharField(label=_("Subject"))
    body = forms.CharField(widget=forms.Textarea(), label=_("Message"))

    def __init__(self, *args, **kwargs):
        self.instance = kwargs.pop('instance')
        self.template = EmailTemplate()
        super(CourseEmailForm, self).__init__(*args, **kwargs)

    def clean(self):
        self.recipient_groups = self.cleaned_data.get('recipients')

        if not self.recipient_groups:
            raise forms.ValidationError(_(u"No recipient selected. Choose at least one group of recipients."))

        return self.cleaned_data

    # returns whether all recepients have an email address
    def all_recepients_reachable(self):
        return self.missing_email_addresses() == 0

    # returns the number of recepients without an email address
    def missing_email_addresses(self):
        recipients = self.template.recipient_list_for_course(self.instance, self.recipient_groups)
        return len([user for user in recipients if not user.email])

    def send(self):
        self.template.subject = self.cleaned_data.get('subject')
        self.template.body = self.cleaned_data.get('body')
        self.template.send_to_users_in_courses([self.instance], self.recipient_groups)
开发者ID:janno42,项目名称:EvaP,代码行数:33,代码来源:forms.py

示例2: test_no_login_url_when_cc_users_in_cc

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_users_in_courses [as 别名]
 def test_no_login_url_when_cc_users_in_cc(self):
     self.user.cc_users.add(self.other_user)
     EmailTemplate.send_to_users_in_courses(self.template, [self.course], [EmailTemplate.CONTRIBUTORS], use_cc=True)
     self.assertEqual(len(mail.outbox), 2)
     self.assertFalse("loginkey" in mail.outbox[0].body)  # message does not contain the login url
     self.assertTrue("loginkey" in mail.outbox[1].body)  # separate email with login url was sent
     self.assertEqual(len(mail.outbox[1].cc), 0)
     self.assertEqual(mail.outbox[1].to, [self.user.email])
开发者ID:Steditor,项目名称:EvaP,代码行数:10,代码来源:test_models.py

示例3: CourseEmailForm

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_users_in_courses [as 别名]
class CourseEmailForm(forms.Form, BootstrapMixin):
    sendToDueParticipants = forms.BooleanField(label=_("Send to participants who didn't vote yet"), required=False, initial=True)
    sendToAllParticipants = forms.BooleanField(label=_("Send to all participants"), required=False)
    sendToResponsible = forms.BooleanField(label=_("Send to the responsible person"), required=False)
    sendToEditors = forms.BooleanField(label=_("Send to editors"), required=False)
    sendToContributors = forms.BooleanField(label=_("Send to all contributors (includes editors)"), required=False)
    subject = forms.CharField(label=_("Subject"))
    body = forms.CharField(widget=forms.Textarea(), label=_("Body"))

    def __init__(self, *args, **kwargs):
        self.instance = kwargs.pop('instance')
        self.template = EmailTemplate()
        super(CourseEmailForm, self).__init__(*args, **kwargs)

    def clean(self):
        self.recipient_groups = []

        if self.cleaned_data.get('sendToAllParticipants'): self.recipient_groups += ['all_participants']
        if self.cleaned_data.get('sendToDueParticipants'): self.recipient_groups += ['due_participants']
        if self.cleaned_data.get('sendToResponsible'): self.recipient_groups += ['responsible']
        if self.cleaned_data.get('sendToEditors'): self.recipient_groups += ['editors']
        if self.cleaned_data.get('sendToContributors'): self.recipient_groups += ['contributors']

        if len(self.recipient_groups) == 0:
            raise forms.ValidationError(_(u"No recipient selected. Choose at least one group of recipients."))

        return self.cleaned_data

    # returns whether all recepients have an email address
    def all_recepients_reachable(self):
        return self.missing_email_addresses() == 0

    # returns the number of recepients without an email address
    def missing_email_addresses(self):
        recipients = self.template.recipient_list_for_course(self.instance, self.recipient_groups)
        return len([user for user in recipients if not user.email])

    def send(self):
        self.template.subject = self.cleaned_data.get('subject')
        self.template.body = self.cleaned_data.get('body')
        self.template.send_to_users_in_courses([self.instance], self.recipient_groups)
开发者ID:Nef10,项目名称:EvaP,代码行数:43,代码来源:forms.py

示例4: send

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_users_in_courses [as 别名]
 def send(self):
     self.template.subject = self.cleaned_data.get('subject')
     self.template.body = self.cleaned_data.get('body')
     EmailTemplate.send_to_users_in_courses(self.template, [self.instance], self.recipient_groups)
开发者ID:anukat2015,项目名称:EvaP,代码行数:6,代码来源:forms.py

示例5: test_login_url_when_use_cc_is_false

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_users_in_courses [as 别名]
 def test_login_url_when_use_cc_is_false(self):
     # message is not sent to others in cc
     self.user.delegates.add(self.other_user)
     EmailTemplate.send_to_users_in_courses(self.template, [self.course], [EmailTemplate.CONTRIBUTORS], use_cc=False)
     self.assertEqual(len(mail.outbox), 1)
     self.assertTrue("loginkey" in mail.outbox[0].body)  # message does contain the login url
开发者ID:Steditor,项目名称:EvaP,代码行数:8,代码来源:test_models.py

示例6: test_login_url_when_nobody_in_cc

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_users_in_courses [as 别名]
 def test_login_url_when_nobody_in_cc(self):
     # message is not sent to others in cc
     EmailTemplate.send_to_users_in_courses(self.template, [self.course], [EmailTemplate.CONTRIBUTORS], use_cc=True)
     self.assertEqual(len(mail.outbox), 1)
     self.assertTrue("loginkey" in mail.outbox[0].body)  # message does contain the login url
开发者ID:Steditor,项目名称:EvaP,代码行数:7,代码来源:test_models.py

示例7: send

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_users_in_courses [as 别名]
 def send(self, request):
     self.template.subject = self.cleaned_data.get('subject')
     self.template.body = self.cleaned_data.get('body')
     EmailTemplate.send_to_users_in_courses(self.template, [self.course], self.recipient_groups, use_cc=True, request=request)
开发者ID:JenniferStamm,项目名称:EvaP,代码行数:6,代码来源:forms.py

示例8: send

# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import send_to_users_in_courses [as 别名]
 def send(self):
     self.template.subject = self.cleaned_data.get("subject")
     self.template.body = self.cleaned_data.get("body")
     EmailTemplate.send_to_users_in_courses(self.template, [self.instance], self.recipient_groups, use_cc=True)
开发者ID:Steditor,项目名称:EvaP,代码行数:6,代码来源:forms.py


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