예제 #1
0
 def __init__(self, pid, event_list):
     self.pid = pid
     self.place = place_name(pid)
     self.province_id = pid_province(pid)
     event_list.sort(key=lambda x: x.begin_time)
     Po.mc_bind(event_list, 'po', 'id')
     self.event_list = event_list
예제 #2
0
 def __init__(self, pid, event_list):
     self.pid = pid
     self.place = place_name(pid)
     self.province_id = pid_province(pid)
     event_list.sort(key=lambda x: x.begin_time)
     Po.mc_bind(event_list, 'po', 'id')
     self.event_list = event_list
예제 #3
0
def event_city_info(event_city_list, pid):
    event_city_list.sort(reverse=True, key=lambda x: city_event_weight(x, pid))
    count = 0
    place = ''
    if pid:
        first = event_city_list[0]
        if first.pid == pid:
            count = len(first.event_list)
            place = PID2NAME[pid]
        else:
            province_id = pid_province(pid)
            #print place_name(province_id)
            li = filter(lambda x: x.province_id == province_id, event_city_list)
            if li:
                count = sum([len(i.event_list) for i in li])
                place = place_name(province_id)

    return event_city_list, count, place
예제 #4
0
def event_city_info(event_city_list, pid):
    event_city_list.sort(reverse=True, key=lambda x: city_event_weight(x, pid))
    count = 0
    place = ''
    if pid:
        first = event_city_list[0]
        if first.pid == pid:
            count = len(first.event_list)
            place = PID2NAME[pid]
        else:
            province_id = pid_province(pid)
            #print place_name(province_id)
            li = filter(lambda x: x.province_id == province_id,
                        event_city_list)
            if li:
                count = sum([len(i.event_list) for i in li])
                place = place_name(province_id)

    return event_city_list, count, place
예제 #5
0
 def place_home(self):
     return place_name(self.pid_home)
예제 #6
0
 def place_now(self):
     return place_name(self.pid_now)
예제 #7
0
 def place_now(self):
     return place_name(self.pid_now)
예제 #8
0
 def place_home(self):
     return place_name(self.pid_home)
예제 #9
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
예제 #10
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