예제 #1
0
def po_audio_new(user_id, name, txt, audio, state, zsite_id):

    if not name and not txt:
        return

    name = name or time_title()

    m = po_new(CID_AUDIO, user_id, name, state, rid=0, zsite_id=zsite_id)
    if m:
        audio_save(m.id, audio)
        m.txt_set(txt)
        m.feed_new()
        return m
예제 #2
0
def po_audio_new(user_id, name, txt, audio, state, zsite_id):

    if not name and not txt:
        return

    name = name or time_title()

    m = po_new(CID_AUDIO, user_id, name, state, rid=0, zsite_id=zsite_id)
    if m:
        audio_save(m.id, audio)
        m.txt_set(txt)
        m.feed_new()
        return m
예제 #3
0
def main():
    for vote in ormiter(Feed, 'rid !=0'):
        recommend = po_new(CID_REC,
                           vote.zsite_id,
                           '',
                           state=STATE_ACTIVE,
                           rid=vote.rid,
                           id=vote.id)
        if recommend:
            mc_po_recommend_id_by_rid_user_id.set(
                '%s_%s' % (vote.rid, vote.zsite_id), recommend.id)
            vote.cid = CID_REC
            vote.rid = 0
            vote.save()
예제 #4
0
    def post(self, id=0):
        user_id = self.current_user_id

        if id:
            event = Event.mc_get(id)
            if event.zsite_id != self.current_user_id:
                return self.redirect('/%s'%id)
            can_change = event.can_change()
        else:
            event = None
            can_change = True

        event = po_event_edit_post(self, id, event, can_change, event_new_if_can_change)
        if event:
            if not id:
                id = event.id
                zsite = self.zsite
                zsite_id = zsite_id_by_zsite_user_id(zsite, user_id)
                po_new(CID_EVENT, user_id, '', STATE_SECRET, id=id, zsite_id=zsite_id)

            if event.state <= EVENT_STATE_TO_REVIEW:
                return self.redirect('/po/edit/%s'%id)
            else:
                return self.redirect('/%s'%id)
예제 #5
0
def po_photo_new(user_id, name, txt, img, state=STATE_ACTIVE, zsite_id=0):
    if not name and not txt:
        return

    name = name or time_title()

    rid = photo_new(user_id, img)

    m = po_new(CID_PHOTO, user_id, name, state, rid, zsite_id=zsite_id)
    if m:
        id = m.id
        m.txt_set(txt)
        if state > STATE_SECRET:
            m.feed_new()

        return m
예제 #6
0
def po_photo_new(user_id, name, txt, img, state=STATE_ACTIVE, zsite_id=0):
    if not name and not txt:
        return

    name = name or time_title()

    rid = photo_new(user_id, img)

    m = po_new(CID_PHOTO, user_id, name, state, rid, zsite_id=zsite_id)
    if m:
        id = m.id
        m.txt_set(txt)
        if state > STATE_SECRET:
            m.feed_new()

        return m
예제 #7
0
def po_video_new(user_id, name, txt, uri, video_site, state, zsite_id):

    if not name and not txt:
        return

    name = name or time_title()

    if not is_same_post(user_id, name, txt, uri):
        m = po_new(
            CID_VIDEO, user_id, name, state, video_site,
            zsite_id=zsite_id
        )
        if m:
            video_new(m.id , uri)
            m.txt_set(txt)
            m.feed_new()
            return m
예제 #8
0
def main():
    for vote in ormiter(Feed,'rid !=0'):
        recommend = po_new(
            CID_REC,
            vote.zsite_id,
            '',
            state=STATE_ACTIVE,
            rid=vote.rid,
            id=vote.id
        )
        if recommend:
            mc_po_recommend_id_by_rid_user_id.set(
                '%s_%s'%(vote.rid, vote.zsite_id),
                recommend.id
            )
            vote.cid  =CID_REC
            vote.rid = 0
            vote.save()
예제 #9
0
def po_video_new(user_id, name, txt, uri, video_site, state, zsite_id):

    if not name and not txt:
        return

    name = name or time_title()

    if not is_same_post(user_id, name, txt, uri):
        m = po_new(CID_VIDEO,
                   user_id,
                   name,
                   state,
                   video_site,
                   zsite_id=zsite_id)
        if m:
            video_new(m.id, uri)
            m.txt_set(txt)
            m.feed_new()
            return m
def save_event(self, phone, address, begin_time, end_time, title, intro, douban_event_id , typ):

    begin_time = time_by_string(begin_time)
    end_time = time_by_string(end_time)

    if begin_time < datetime.now():
        return None

    if typ in EVENT_DICT:
        event_cid = EVENT_DICT[typ]
    else:
        event_cid = EVENT_DICT[u'其他']

    city = address[0]
    place = address[1]
    if len(address) == 2:
        address = address[1]
    else:
        address = address[2]


    city_pid = location_finder(city)
    pid = location_finder(place)

    if pid not in PLACE_L1L2[city_pid]:
        pid = city_pid

    begin = datetime_to_minutes(begin_time)
    end = datetime_to_minutes(end_time)

    id = 0
    limit_up = 42
    limit_down = 0
    transport = ''
    price = 0

    event = event_new(
        self.user_id,
        event_cid,
        city_pid,
        pid,
        address,
        transport,
        begin,
        end,
        0,
        limit_up,
        limit_down,
        phone,
        0,
        id
    )

    id = event.id


    po = po_new(CID_EVENT, self.user_id, '', STATE_SECRET , id=id, zsite_id=self.zsite_id)
    if po:
        po.name_ = title
        po.txt_set(htm2txt(intro)[0])
        po.save()

        event_init2to_review(id)
        import_douban_event = ImportDoubanEvent.get_or_create(id=int(douban_event_id))
        import_douban_event.event_id = id
        import_douban_event.save()

        return event