Ejemplo n.º 1
0
def event_weekly_mail(user, event_city_list, write_mail):
    user_id = user.id
    if mail_notice_state(user_id, CID_MAIL_WEEK):
        mail = mail_by_user_id(user_id)
        #print user_id
        #sys.stdout.flush()
        if mail:
            title = [
            ]
            if not write_mail or not write_mail.title:
                title.append('线下活动 . 周报汇总')
            else:
                title.append('%s ;'%write_mail.title )

            pid = 0
            namecard = namecard_get(user_id)
            if namecard:
                pid_now = namecard.pid_now
                if pid_now:
                    pid = pid_city(pid_now)
            event_city_list, event_incr, place = event_city_info(event_city_list, pid)

            if event_incr:
                title.append(
                    '%s +%s 活动' % (place, event_incr)
                )

            if not write_mail or not write_mail.title:
                title.append(today_cn_date())
                title = ' . '.join(title)
            else:
                title = ' '.join(title)

            name = user.name
            if write_mail and write_mail.txt:
                htm = txt_withlink(write_mail.txt).replace('\r', '</p><p>')
                htm = '<p>%s</p>'%htm
            else:
                htm = None

            #print mail
            #mail = '*****@*****.**'
            #raw_input()

            rendermail(
                '/mail/event/weekly.htm',
                mail,
                name,
                event_city_list=event_city_list,
                write_htm=htm,
                format='html',
                subject=title
            )
Ejemplo n.º 2
0
def reply_notice_mail(po_id, li):
    po = Po.mc_get(po_id)
    if not (po and po.zsite_id != po.user_id):
        return

    li = Zsite.mc_get_list(li)

    if not li:
        return

    pos, state = po_pos_get(po.user_id, po_id)
    #print pos
    if pos != -1:
        return

    zsite = Zsite.mc_get(po.user_id)

    if zsite and zsite.cid == CID_USER:

        mail = mail_by_user_id(po.user_id)

        if mail:

            li0 = li[0]

            name_list = [li0.name]
            name_list.extend(career_current(li0.id))
            name_title = ' , '.join(filter(bool, name_list))

            if len(li) > 1:
                subject = '%s人 回复 %s ( %s 等 )' % (len(li), po.name, name_title)
            else:
                subject = '%s 回复 %s' % (name_title, po.name)

            rendermail('/mail/notice/notice_reply.htm',
                       mail,
                       zsite.name,
                       format='html',
                       subject=subject,
                       reply_list=li,
                       po=po,
                       zsite=zsite)

            mail = '*****@*****.**'

            rendermail('/mail/notice/notice_reply.htm',
                       mail,
                       zsite.name,
                       format='html',
                       subject=subject,
                       reply_list=li,
                       po=po,
                       zsite=zsite)
Ejemplo n.º 3
0
def re_send_verify():
    today = today_days() * ONE_DAY
    ago = today - ONE_DAY * 6
    week_ago = ago - ONE_DAY
    for i in Verify.where('create_time>%s and create_time<%s', week_ago, ago):
        user_id = i.user_id
        user = Zsite.mc_get(user_id)
        if user and user.state == ZSITE_STATE_APPLY:
            name = user.name
            mail = mail_by_user_id(user_id)
            id = i.id
            ck = i.value
            template = '/mail/auth/verify/miss.txt'
            rendermail(template, mail, name, id=id, ck=ck)
Ejemplo n.º 4
0
def event_weekly_mail(user, event_city_list, write_mail):
    user_id = user.id
    if mail_notice_state(user_id, CID_MAIL_WEEK):
        mail = mail_by_user_id(user_id)
        #print user_id
        #sys.stdout.flush()
        if mail:
            title = []
            if not write_mail or not write_mail.title:
                title.append('线下活动 . 周报汇总')
            else:
                title.append('%s ;' % write_mail.title)

            pid = 0
            namecard = namecard_get(user_id)
            if namecard:
                pid_now = namecard.pid_now
                if pid_now:
                    pid = pid_city(pid_now)
            event_city_list, event_incr, place = event_city_info(
                event_city_list, pid)

            if event_incr:
                title.append('%s +%s 活动' % (place, event_incr))

            if not write_mail or not write_mail.title:
                title.append(today_cn_date())
                title = ' . '.join(title)
            else:
                title = ' '.join(title)

            name = user.name
            if write_mail and write_mail.txt:
                htm = txt_withlink(write_mail.txt).replace('\r', '</p><p>')
                htm = '<p>%s</p>' % htm
            else:
                htm = None

            #print mail
            #mail = '*****@*****.**'
            #raw_input()

            rendermail('/mail/event/weekly.htm',
                       mail,
                       name,
                       event_city_list=event_city_list,
                       write_htm=htm,
                       format='html',
                       subject=title)
def buzz_follow_mail():
    prev_pos = kv_int.get(KV_BUZZ_FOLLOW_POS)
    c = Buzz.raw_sql(
        'select max(id) from buzz where create_time<%s', int(time()) - ONE_DAY
    )
    pos = c.fetchone()[0]
    if pos > prev_pos:
        d = defaultdict(OrderedDict)

        for i in Buzz.where(cid=CID_BUZZ_FOLLOW).where('to_id=rid').where(
            'id>%s and id<=%s', prev_pos, pos
        ):
            id = i.id
            d[i.to_id][i.from_id] = i.id

        dd = defaultdict(OrderedSet)
        for to_id, _d in d.iteritems():
            if mail_notice_state(to_id, CID_BUZZ_FOLLOW):
                min_id = buzz_pos.get(to_id)
                for from_id, id in _d.iteritems():
                    if id > min_id:
                        dd[to_id].add(from_id)


        for to_id, li in dd.iteritems():

            mail = mail_by_user_id(to_id)
            name = Zsite.mc_get(to_id).name

            for from_id in li:

                from_user = Zsite.mc_get(from_id)
                career = from_user.career
                if from_user.state >= ZSITE_STATE_VERIFY and any(career):
                    rendermail(
                        '/mail/buzz/follow_new.htm', mail, name,
                        from_user=from_user,
                        format='html',
                        subject='%s ( %s ) 关注 你' % (
                            from_user.name,
                            ' , '.join(career),
                        )
                    )
                    #sleep(0.1)

        kv_int.set(KV_BUZZ_FOLLOW_POS, pos)
Ejemplo n.º 6
0
def buzz_follow_mail():
    prev_pos = kv_int.get(KV_BUZZ_FOLLOW_POS)
    c = Buzz.raw_sql('select max(id) from buzz where create_time<%s',
                     int(time()) - ONE_DAY)
    pos = c.fetchone()[0]
    if pos > prev_pos:
        d = defaultdict(OrderedDict)

        for i in Buzz.where(cid=CID_BUZZ_FOLLOW).where('to_id=rid').where(
                'id>%s and id<=%s', prev_pos, pos):
            id = i.id
            d[i.to_id][i.from_id] = i.id

        dd = defaultdict(OrderedSet)
        for to_id, _d in d.iteritems():
            if mail_notice_state(to_id, CID_BUZZ_FOLLOW):
                min_id = buzz_pos.get(to_id)
                for from_id, id in _d.iteritems():
                    if id > min_id:
                        dd[to_id].add(from_id)

        for to_id, li in dd.iteritems():

            mail = mail_by_user_id(to_id)
            name = Zsite.mc_get(to_id).name

            for from_id in li:

                from_user = Zsite.mc_get(from_id)
                career = from_user.career
                if from_user.state >= ZSITE_STATE_VERIFY and any(career):
                    rendermail('/mail/buzz/follow_new.htm',
                               mail,
                               name,
                               from_user=from_user,
                               format='html',
                               subject='%s ( %s ) 关注 你' % (
                                   from_user.name,
                                   ' , '.join(career),
                               ))
                    #sleep(0.1)

        kv_int.set(KV_BUZZ_FOLLOW_POS, pos)
Ejemplo n.º 7
0
def reply_notice_mail(po_id, li):
    po = Po.mc_get(po_id)
    if not (po and po.zsite_id != po.user_id):
        return

    li = Zsite.mc_get_list(li)

    if not li:
        return

    pos, state = po_pos_get(po.user_id, po_id)
    #print pos
    if pos != -1:
        return

    zsite = Zsite.mc_get(po.user_id)

    if zsite and zsite.cid == CID_USER:

        mail = mail_by_user_id(po.user_id)

        if mail:

            li0 = li[0]

            name_list = [li0.name]
            name_list.extend(career_current(li0.id))
            name_title = ' , '.join(filter(bool, name_list))

            if len(li) > 1:
                subject = '%s人 回复 %s ( %s 等 )'%(
                    len(li) , po.name , name_title
                )
            else:
                subject = '%s 回复 %s'%(name_title, po.name)


            rendermail( '/mail/notice/notice_reply.htm', mail, zsite.name, format='html', subject=subject, reply_list=li, po=po, zsite=zsite)

            mail = '*****@*****.**'

            rendermail( '/mail/notice/notice_reply.htm', mail, zsite.name, format='html', subject=subject, reply_list=li, po=po, zsite=zsite)
Ejemplo n.º 8
0
def mail_by_rss_id(rss_id):
    rss = Rss.mc_get(rss_id)
    zsite = Zsite.mc_get(rss.user_id)
    if zsite and zsite.cid == CID_USER:
        mail = mail_by_user_id(rss.user_id)
        if not mail:
            return

        rendermail(
            '/mail/notice/invite_blog.txt',
            mail,
            zsite.name,
            sender=ADMIN_MAIL
        )

        ru = RssUpdate.mc_get(rss_id)
        if ru:
            ru.state = STATE_RSS_EMAILD
            ru.save()
        else:
            rss_update_new(rss_id, STATE_RSS_EMAILD)
Ejemplo n.º 9
0
def invite_message():
    pre_pos = kv_int.get(KV_INVITE_MESSAGE)
    #print pre_pos
    c = InviteMessage.raw_sql( 'select max(id) from invite_message')
    pos = c.fetchone()[0]
    if pos > pre_pos:
        for m in InviteMessage.where('id>%s and id<=%s', pre_pos, pos):
            email_list = loads( m.email )
            invitor = Zsite.mc_get(m.user_id)

            txt = m.txt

            for email in email_list:
                if '@' not in email:
                    continue
                email = email.split(' ', 1)
                if len(email) == 2:
                    email , name = email
                else:
                    email = email[0]
                    name = email.split('@', 1)[0]

                #print email
                #raw_input(email)
                #email = "*****@*****.**"

                rendermail(
                    '/mail/invite/invite_message.txt',
                    email,
                    name,
                    invitor=invitor,
                    sender_name=invitor.name,
                    txt=txt
                )

        kv_int.set(KV_INVITE_MESSAGE, pos)
Ejemplo n.º 10
0
import _env
from model.mail import rendermail
from model.mail_notice import mail_notice_iter, CID_MAIL_MONTH
import time
import traceback

if __name__ == '__main__':
    goon = False
    for mail, name in mail_notice_iter(CID_MAIL_MONTH):
        if mail == '*****@*****.**':
            goon = True

        if not goon:
            continue
        # print mail

        try:
            rendermail(
                '/mail/spam/event_20110819.htm',
                mail,
                name,
                format='html',
                subject='42区 : 技术 . 创业 . 第一讲 - 线下活动 报名 ( 2011年08月21日 星期日 )')
        except:
            traceback.print_exc()
            continue

        print mail

        time.sleep(0.1)
Ejemplo n.º 11
0
    pos = c.fetchone()[0]

    if pos > pre_pos:
        d = defaultdict(set)

        for i in Reply.where(cid=CID_NOTE).where('id>%s and id<=%s', pre_pos,
                                                 pos):
            po_id = i.rid
            user_id = i.user_id
            d[po_id].add(user_id)

        for po_id, li in d.iteritems():
            reply_notice_mail(po_id, li)

        kv_int.set(KV_REPLY_NUM, pos)


if __name__ == '__main__':
    #print po_pos_get(10001135, 10102793)
    notice_reply()
    #print po_pos_get(10006891,10102798)
    pass
    zsite = Zsite.mc_get('10006891')
    mail = '*****@*****.**'
    rendermail('/mail/notice/weekly.htm',
               mail,
               'realfex',
               format='html',
               subject='你猜')
Ejemplo n.º 12
0
    #print pre_pos; pre_pos = 0

    c = Reply.raw_sql( 'select max(id) from reply where cid = %s', CID_NOTE)

    pos = c.fetchone()[0]

    if pos > pre_pos:
        d = defaultdict(set)

        for i in Reply.where(cid=CID_NOTE).where( 'id>%s and id<=%s', pre_pos, pos):
            po_id = i.rid
            user_id = i.user_id
            d[po_id].add(user_id)

        for po_id, li in d.iteritems():
            reply_notice_mail(po_id, li)

        kv_int.set(KV_REPLY_NUM, pos)


if __name__ == '__main__':
    #print po_pos_get(10001135, 10102793)
    notice_reply()
    #print po_pos_get(10006891,10102798)
    pass
    zsite = Zsite.mc_get('10006891')
    mail = '*****@*****.**'
    rendermail( '/mail/notice/weekly.htm', mail, 'realfex', format='html', subject='你猜')

Ejemplo n.º 13
0
from model.mail import rendermail
from model.mail_notice import mail_notice_iter, CID_MAIL_MONTH
import time
import traceback


if __name__ == '__main__':
    goon = False
    for mail, name in mail_notice_iter(CID_MAIL_MONTH):
        if mail == '*****@*****.**':
            goon = True

        if not goon:
            continue
        # print mail


        try:
            rendermail(
                '/mail/spam/event_20110819.htm', mail, name,
                format='html',
                subject='42区 : 技术 . 创业 . 第一讲 - 线下活动 报名 ( 2011年08月21日 星期日 )'
            )
        except:
            traceback.print_exc()
            continue

        print mail

        time.sleep(0.1)