tasks.py 文件源码

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

项目:socialhome 作者: jaywink 项目源码 文件源码
def send_share_notification(share_id):
    """Super simple you're content has been shared notification to a user."""
    if settings.DEBUG:
        return
    try:
        content = Content.objects.get(id=share_id, content_type=ContentType.SHARE, share_of__local=True)
    except Content.DoesNotExist:
        logger.warning("No share content found with id %s", share_id)
        return
    content_url = "%s%s" % (settings.SOCIALHOME_URL, content.share_of.get_absolute_url())
    subject = _("New share of: %s" % content.share_of.short_text_inline)
    context = get_common_context()
    context.update({
        "subject": subject, "actor_name": content.author.name_or_handle,
        "actor_url": "%s%s" % (settings.SOCIALHOME_URL, content.author.get_absolute_url()),
        "content_url": content_url, "name": content.share_of.author.name_or_handle,
    })
    send_mail(
        "%s%s" % (settings.EMAIL_SUBJECT_PREFIX, subject),
        render_to_string("notifications/share.txt", context=context),
        settings.DEFAULT_FROM_EMAIL,
        [content.share_of.author.user.email],
        fail_silently=False,
        html_message=render_to_string("notifications/share.html", context=context),
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号