本文整理汇总了Python中evap.evaluation.models.EmailTemplate.recipient_list_for_evaluation方法的典型用法代码示例。如果您正苦于以下问题:Python EmailTemplate.recipient_list_for_evaluation方法的具体用法?Python EmailTemplate.recipient_list_for_evaluation怎么用?Python EmailTemplate.recipient_list_for_evaluation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类evap.evaluation.models.EmailTemplate
的用法示例。
在下文中一共展示了EmailTemplate.recipient_list_for_evaluation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EvaluationEmailForm
# 需要导入模块: from evap.evaluation.models import EmailTemplate [as 别名]
# 或者: from evap.evaluation.models.EmailTemplate import recipient_list_for_evaluation [as 别名]
class EvaluationEmailForm(forms.Form):
recipients = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple(), choices=EmailTemplate.EMAIL_RECIPIENTS, label=_("Send email to"))
subject = forms.CharField(label=_("Subject"))
body = forms.CharField(widget=forms.Textarea(), label=_("Message"))
def __init__(self, *args, evaluation, export=False, **kwargs):
super().__init__(*args, **kwargs)
self.template = EmailTemplate()
self.evaluation = evaluation
self.fields['subject'].required = not export
self.fields['body'].required = not export
def clean(self):
self.recipient_groups = self.cleaned_data.get('recipients')
if not self.recipient_groups:
raise forms.ValidationError(_("No recipient selected. Choose at least one group of recipients."))
return self.cleaned_data
def email_addresses(self):
recipients = self.template.recipient_list_for_evaluation(self.evaluation, self.recipient_groups, filter_users_in_cc=False)
return set(user.email for user in recipients if user.email)
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_evaluations(self.template, [self.evaluation], self.recipient_groups, use_cc=True, request=request)