notification.py 文件源码

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

项目:assethub 作者: portnov 项目源码 文件源码
def on_asset_posted(sender, instance, created, **kwargs):
    print("on_asset_posted: instance={}, created={}".format(instance, created))
    asset = instance
    Event.process(asset, None, created)

# @receiver(notify)
# def on_notify(verb, recipient, sender, **kwargs):
#     print("Notify {0} about {1} {2}".format(recipient.email, sender, verb))
#     subject = None
#     body = None
#     template = None
#     if isinstance(sender, Comment):
#         comment = sender
# #         asset = sender.content_object
# #         if verb == 'was posted' and recipient.profile.email_comments:
# #             subject = 
# #             template = loader.get_template('assets/notification/new_comment_posted.txt')
# #         elif verb == 'mentioned' and recipient.profile.email_mention:
# #             subject = 
# #             template = loader.get_template('assets/notification/mention.txt')
# #         if template:
# #             context = dict(comment=comment, asset=asset, user=recipient)
# #             body = template.render(context)
# 
#     if isinstance(sender, Asset):
#         asset = sender
# #         if verb == 'was posted' and recipient.profile.email_assets:
# #             subject = 
# #             template = loader.get_template('assets/notification/new_asset_posted.txt')
# #         elif verb == 'was updated' and recipient.profile.email_assets:
# #             subject = 
# #             template = loader.get_template('assets/notification/asset_updated.txt')
# #         elif verb == 'mentioned' and recipient.profile.email_mention:
# #             subject = ugettext("[{site}]: You were mentioned").format(site = comment.site.name)
# #             template = loader.get_template('assets/notification/mention.txt')
# #         if template:
# #             context = dict(asset=asset, user=recipient)
# #             body = template.render(context)
# 
#     if subject and body:
#         send_mail(subject, body, settings.DEFAULT_FROM_EMAIL, [recipient.email], fail_silently = False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号