notification.py 文件源码

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

项目:assethub 作者: portnov 项目源码 文件源码
def process(instance, parent, created):
        for info in Event.get(instance, parent, created):
            for recipient in info.recipients:
                if recipient == info.actor:
                    continue
                print("Notify {0} about {1} {2}".format(recipient, instance, info.verb))
                notify.send(info.actor, verb=info.verb, action_object=instance, target=parent, recipient=recipient, template=info.template_name, url=info.url)
                if info.is_user_subscribed(recipient):
                    subject = info.email_subject
                    template = loader.get_template(join('assets', 'notification', info.email_body_template))
                    context = info.email_context
                    context['user'] = recipient
                    body = template.render(context)
                    if subject and body:
                        print("Send mail to {0}: {1}".format(recipient.email, subject).encode('utf-8'))
                        send_mail(subject, body, settings.DEFAULT_FROM_EMAIL, [recipient.email], fail_silently = False)

### Specific events
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号