Exemplo n.º 1
0
def notice_mail_day(to_id, li):
    from user_mail import mail_by_user_id

    to_user = Zsite.mc_get(to_id)
    name = to_user.name
    mail = mail_by_user_id(to_id)
    count = len(li)
    li_wall = []
    _li_wall_reply = defaultdict(list)

    for from_id, cid, rid in li:
        from_user = Zsite.mc_get(from_id)
        if cid == CID_NOTICE_WALL:
            li_wall.append(from_user)
        elif cid == CID_NOTICE_WALL_REPLY:
            o = Wall.mc_get(rid)
            _li_wall_reply[rid].append(from_user)

    li_wall_reply = {}

    for rid, from_list in _li_wall_reply.iteritems():
        o = Wall.mc_get(rid)
        li_wall_reply[o] = from_list

    if li_wall or li_wall_reply:

        subject = render_template(
            '/mail/notice/day_total.txt',
            count=count,
            li_wall=li_wall,
            li_wall_reply=li_wall_reply,
        )

        rendermail(
            '/mail/notice/day_total.htm',
            mail,
            name,
            to_user=to_user,
            li_wall=li_wall,
            li_wall_reply=li_wall_reply,
            format='html',
            subject=subject,
        )