tasks.py 文件源码

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

项目:api-django 作者: lafranceinsoumise 项目源码 文件源码
def send_support_group_changed_notification(support_group_pk, changes):
    try:
        group = SupportGroup.objects.get(pk=support_group_pk, published=True)
    except SupportGroup.DoesNotExist:
        return

    change_descriptions = [desc for label, desc in CHANGE_DESCRIPTION.items() if label in changes]
    change_fragment = render_to_string(
        template_name='lib/list_fragment.html',
        context={'items': change_descriptions}
    )

    # TODO: find adequate way to set up domain names to use for these links
    bindings = {
        "GROUP_NAME": group.name,
        "GROUP_CHANGES": change_fragment,
        "GROUP_LINK": front_url("view_group", kwargs={'pk': support_group_pk})
    }

    notifications_enabled = Q(notifications_enabled=True) & Q(person__group_notifications=True)

    recipients = [membership.person
                  for membership in group.memberships.filter(notifications_enabled).prefetch_related('person__emails')]

    send_mosaico_email(
        code='GROUP_CHANGED',
        subject=_("Les informations de votre groupe d'action ont été changées"),
        from_email=settings.EMAIL_FROM,
        recipients=recipients,
        bindings=bindings,
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号