models.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:praelatus-poc 作者: praelatus 项目源码 文件源码
def email_watchers(sender, instance=None, **kwargs):
    c = {
        'ticket': instance.action_object,
        'actor': instance.actor,
        'verb': instance.verb
    }

    if hasattr(instance, 'description') and instance.description != '':
        c['comment'] = instance.description
        html_content = get_template('email/html/comment.html').render(c)
        text_content = ''
    else:
        html_content = get_template('email/html/transition.html').render(c)
        text_content = get_template('email/text/transition.txt').render(c)

    msg = EmailMultiAlternatives(
        'Ticket Tracking System: ' + instance.action_object.key, text_content,
        settings.EMAIL_ADDRESS,
        [u.email for u in instance.action_object.watching()])

    msg.attach_alternative(html_content, 'text/html')
    msg.send()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号