예제 #1
0
def _po_rm(user_id, po):
    po.state = STATE_RM
    po.save()
    id = po.id
    feed_rm(id)

    from model.po_show import po_show_rm
    po_show_rm(id)

    from model.po_recommend import mq_rm_rec_po_by_po_id
    mq_rm_rec_po_by_po_id(user_id, id)

    from zsite_tag import zsite_tag_rm_by_po
    zsite_tag_rm_by_po(po)

    from po_tag import po_tag_rm_by_po
    po_tag_rm_by_po(po)

    from rank import rank_rm_all
    rank_rm_all(id)

    from po_question import mc_answer_id_get, answer_count
    rid = po.rid
    if rid:
        mc_answer_id_get.delete('%s_%s' % (user_id, rid))
        answer_count.delete(rid)
    mc_flush(user_id, po.cid)
    mq_buzz_po_rm(id)
    from fav import fav_rm_by_po
    fav_rm_by_po(po)
    return True
예제 #2
0
def event_kill(user_id, event, txt):
    from po_event import _po_event_notice_new
    if EVENT_STATE_RM < event.state < EVENT_STATE_END:
        event_id = event.id
        if event.can_change():
            po_rm(user_id, event_id)
        else:
            event.state = EVENT_STATE_RM
            event.save()
            zsite_id = event.zsite_id
            feed_rm(event_id)
            mc_flush_by_zsite_id(zsite_id)
            event_to_review_count_by_zsite_id.delete(user_id)
            mc_flush_by_user_id_event_id_owner_id(user_id, id, zsite_id)

        o = _po_event_notice_new(user_id, event_id, txt)
        mq_event_kill_extra(user_id, event_id, o.id)
        mc_flush_by_city_pid_cid(event.city_pid, event.cid)
예제 #3
0
def event_kill(user_id, event, txt):
    from po_event import _po_event_notice_new
    if EVENT_STATE_RM < event.state < EVENT_STATE_END:
        event_id = event.id
        if event.can_change():
            po_rm(user_id, event_id)
        else:
            event.state = EVENT_STATE_RM
            event.save()
            zsite_id = event.zsite_id
            feed_rm(event_id)
            mc_flush_by_zsite_id(zsite_id)
            event_to_review_count_by_zsite_id.delete(user_id)
            mc_flush_by_user_id_event_id_owner_id(user_id, id, zsite_id)

        o = _po_event_notice_new(user_id, event_id, txt)
        mq_event_kill_extra(user_id, event_id, o.id)
        mc_flush_by_city_pid_cid(event.city_pid, event.cid)
예제 #4
0
def po_state_set(po, state):
    old_state = po.state
    if old_state == state:
        return
    po.state = state
    po.save()
    cid = po.cid
    mc_flush_other(po.user_id, cid)
    mc_flush_zsite_cid(po.zsite_id, cid)
    id = po.id
    if old_state > STATE_SECRET and state == STATE_SECRET:
        feed_rm(id)
        po.tag_rm()
        mq_buzz_po_rm(id)
        from fav import fav_rm_by_po
        fav_rm_by_po(po)
    elif old_state < STATE_ACTIVE and state >= STATE_ACTIVE:
        po.feed_new()
        po.tag_new()
예제 #5
0
def feed_tuple_by_db(id):
    m = Po.mc_get(id)
    if not m:
        feed_rm(id)
    cid = m.cid
    rid = m.rid
    has_question = cid in (CID_WORD, CID_ANSWER)

    if rid and has_question:
        question = m.target
        name = question.name
    elif cid == CID_REC:
        name = m.name_htm
    elif cid != CID_WORD:
        name = m.name
    else:
        name = None

    #if cid == CID_QUESTION:
    #    reply_count = answer_count(id)
    #else:
    reply_count = m.reply_count
    if cid == CID_PHOTO:
        rid = fs_url_jpg(721, rid)
    elif cid == CID_AUDIO:
        rid = fs_url_audio(id, '')
    elif cid == CID_VIDEO:
        rid = video_link_autoplay(rid, id)
    elif cid == CID_EVENT:
        event = Event.mc_get(id)
        feed_rm(id)
        rid = fs_url_jpg(162, event.pic_id)
    else:
        rid = rid

    result = [
        m.user_id,
        cid,
        rid,
        m.zsite_id,
        reply_count,
        m.create_time,
        name,
        #vote_count(id)
    ]

    txt = m.txt
    if cid != CID_WORD:
        txt, has_more = cnenoverflow(txt, 100)
        if not has_more:
            txt = m.htm
        result.extend((txt, has_more))
    else:
        txt = txt_withlink(txt)
        result.extend((txt, False))

    if cid == CID_EVENT:
        result.append(place_name(event.pid))
        result.append(event.address)
        result.extend(begin_end_by_minute(event.begin_time, event.end_time))
    elif rid and has_question:
        user = question.user
        result.extend((question.id, user.name, user.link))

    return result
예제 #6
0
def render_feed_by_zsite_id(zsite_id, limit=MAXINT, begin_id=MAXINT):
    zsite_id_list = zsite_id_list_by_follow(zsite_id)
    rt_dict = defaultdict(list)

    id_list = []
    id = 0
    for i in feed_merge_iter(zsite_id_list, limit, begin_id):
        id = i.id
        po = Po.mc_get(id)
        if po is None:
            continue
        if po.cid == CID_REC:
            id = po.rid
            od = rt_dict[id]
            user_id = po.user_id
            data = (po.id, po.txt, po.user_id)
            od.append(data)
        else:
            id = po.id

        if id not in id_list:
            id_list.append(id)

    return render_feed_list(id_list, zsite_id, rt_dict), id


if __name__ == '__main__':
    feed_rm(10187807)
    for i in render_feed_by_zsite_id(10071241, 100):
        pass
예제 #7
0
def feed_tuple_by_db(id):
    m = Po.mc_get(id)
    if not m:
        feed_rm(id)
    cid = m.cid
    rid = m.rid
    has_question = cid in (CID_WORD, CID_ANSWER)

    if rid and has_question:
        question = m.target
        name = question.name
    elif cid == CID_REC:
        name = m.name_htm
    elif cid != CID_WORD:
        name = m.name
    else:
        name = None

    #if cid == CID_QUESTION:
    #    reply_count = answer_count(id)
    #else:
    reply_count = m.reply_count
    if cid == CID_PHOTO:
        rid = fs_url_jpg(721, rid)
    elif cid == CID_AUDIO:
        rid = fs_url_audio(id, '')
    elif cid == CID_VIDEO:
        rid = video_link_autoplay(rid, id)
    elif cid == CID_EVENT:
        event = Event.mc_get(id)
        feed_rm(id)
        rid = fs_url_jpg(162, event.pic_id)
    else:
        rid = rid

    result = [
        m.user_id,
        cid,
        rid,
        m.zsite_id,
        reply_count,
        m.create_time,
        name,
        #vote_count(id)
    ]

    txt = m.txt
    if cid != CID_WORD:
        txt, has_more = cnenoverflow(txt, 100)
        if not has_more:
            txt = m.htm
        result.extend((txt, has_more))
    else:
        txt = txt_withlink(txt)
        result.extend((txt, False))

    if cid == CID_EVENT:
        result.append(place_name(event.pid))
        result.append(event.address)
        result.extend(
            begin_end_by_minute(event.begin_time, event.end_time)
        )
    elif rid and has_question:
        user = question.user
        result.extend(
            (question.id, user.name, user.link)
        )

    return result
예제 #8
0
    zsite_id_list = zsite_id_list_by_follow(zsite_id)
    rt_dict = defaultdict(list)

    id_list = []
    id = 0
    for i in feed_merge_iter(zsite_id_list, limit, begin_id):
        id = i.id
        po = Po.mc_get(id)
        if po is None:
            continue
        if po.cid == CID_REC:
            id = po.rid
            od = rt_dict[id]
            user_id = po.user_id
            data = (po.id, po.txt,po.user_id)
            od.append(data)
        else:
            id = po.id

        if id not in id_list:
            id_list.append(id)


    return render_feed_list(id_list, zsite_id, rt_dict), id


if __name__ == '__main__':
    feed_rm(10187807)
    for i in render_feed_by_zsite_id(10071241, 100):
        pass