Пример #1
0
def po_new(cid, user_id, name, state, rid=0, id=None, zsite_id=0):
    if is_spammer(user_id):
        return
    if state is None:
        if zsite_id and zsite_id != user_id:
            state = STATE_PO_ZSITE_SHOW_THEN_REVIEW
        else:
            state = STATE_ACTIVE


    m = Po(
        id=id or gid(),
        name_=cnencut(name, 142),
        user_id=user_id,
        cid=cid,
        rid=rid,
        state=state,
        zsite_id=zsite_id,
        create_time=int(time()),
    )
    m.save()

    if cid != CID_NOTE: #NOTE 可能是导入 , 通过po pos的状态判断是不是要发邮件
        from po_pos import po_pos_set
        po_pos_set(user_id, m)

    mc_flush(user_id, cid)

    if state >= STATE_ACTIVE:
        m.tag_new()

    mc_flush_zsite_cid(zsite_id, cid)
    return m
Пример #2
0
def oauth_client_new(user_id, name, txt, site, cid=0):
    secret = uuid4().bytes
    id = gid()
    o = OauthClient(id=id, user_id=user_id, secret=secret, name=name, site=site, cid=cid)
    o.save()
    txt_new(id, txt)
    mc_oauth_client_id_by_user_id.delete(user_id)
    return o
Пример #3
0
def event_new(
    zsite_id,
    cid,
    city_pid,
    pid,
    address,
    transport,
    begin_time,
    end_time,
    cent,
    limit_up,
    limit_down,
    phone,
    pic_id,
    id=None
):
    if id:
        event = Event.mc_get(id)
        if event.zsite_id == zsite_id:
            event.cid = cid
            event.city_pid = city_pid
            event.pid = pid
            event.address = address
            event.transport = transport
            event.begin_time = begin_time
            event.end_time = end_time
            event.cent = cent
            event.limit_up = limit_up
            event.limit_down = limit_down
            event.phone = phone
            event.pic_id = pic_id
            #event.state=EVENT_STATE_INIT
            event.save()
    else:
        event = Event(
            id=gid(),
            zsite_id=zsite_id,
            cid=cid,
            city_pid=city_pid,
            pid=pid,
            address=address,
            transport=transport,
            begin_time=begin_time,
            end_time=end_time,
            cent=cent,
            limit_up=limit_up,
            limit_down=limit_down,
            phone=phone,
            pic_id=pic_id,
            state=EVENT_STATE_INIT
        )
        event.save()
        mc_flush_by_zsite_id(zsite_id)

    return event
Пример #4
0
def zsite_new(name, cid, state=ZSITE_STATE_APPLY, id=None):
    if id is None:
        id = gid()
    zsite = Zsite(id=id, cid=cid, name=name, state=state)
    zsite.save()
    #    page = Zpage(
    #        zsite_id=zsite.id,
    #        name=ZPAGE_NAME,
    #        state=ZPAGE_STATE_INDEX
    #    )
    #    page.save()
    return zsite
Пример #5
0
def zsite_new(name, cid, state=ZSITE_STATE_APPLY, id=None):
    if id is None:
        id = gid()
    zsite = Zsite(id=id, cid=cid, name=name, state=state)
    zsite.save()
#    page = Zpage(
#        zsite_id=zsite.id,
#        name=ZPAGE_NAME,
#        state=ZPAGE_STATE_INDEX
#    )
#    page.save()
    return zsite
Пример #6
0
def oauth_client_new(user_id, name, txt, site, cid=0):
    secret = uuid4().bytes
    id = gid()
    o = OauthClient(id=id,
                    user_id=user_id,
                    secret=secret,
                    name=name,
                    site=site,
                    cid=cid)
    o.save()
    txt_new(id, txt)
    mc_oauth_client_id_by_user_id.delete(user_id)
    return o
Пример #7
0
def event_new(zsite_id,
              cid,
              city_pid,
              pid,
              address,
              transport,
              begin_time,
              end_time,
              cent,
              limit_up,
              limit_down,
              phone,
              pic_id,
              id=None):
    if id:
        event = Event.mc_get(id)
        if event.zsite_id == zsite_id:
            event.cid = cid
            event.city_pid = city_pid
            event.pid = pid
            event.address = address
            event.transport = transport
            event.begin_time = begin_time
            event.end_time = end_time
            event.cent = cent
            event.limit_up = limit_up
            event.limit_down = limit_down
            event.phone = phone
            event.pic_id = pic_id
            #event.state=EVENT_STATE_INIT
            event.save()
    else:
        event = Event(id=gid(),
                      zsite_id=zsite_id,
                      cid=cid,
                      city_pid=city_pid,
                      pid=pid,
                      address=address,
                      transport=transport,
                      begin_time=begin_time,
                      end_time=end_time,
                      cent=cent,
                      limit_up=limit_up,
                      limit_down=limit_down,
                      phone=phone,
                      pic_id=pic_id,
                      state=EVENT_STATE_INIT)
        event.save()
        mc_flush_by_zsite_id(zsite_id)

    return event
Пример #8
0
    def reply_new(self, user, txt, state=STATE_ACTIVE, create_time=None):
        from zsite import user_can_reply
        user_id = user.id
        cid = self.cid
        if cid not in (CID_SITE, CID_COM):
            if not user_can_reply(user):
                return
        if is_spammer(user_id):
            return

        txt = txt.rstrip()
        rid = self.id


        if not txt or is_same_post(user_id, cid, rid, txt, state):
            return

        id = gid()
        if not create_time:
            create_time = int(time())
        txt_new(id, txt)
        cursor = self.reply_cursor
        cursor.execute(
            'insert into reply (id,cid,create_time,state,rid,user_id) values (%s,%s,%s,%%s,%%s,%%s)' % (
                id,
                cid,
                create_time,
            ),
            (state, rid, user_id)
        )
        cursor.connection.commit()
        mc_flush_reply_id_list(cid, rid)

#            key = '%s_%s' % (rid, user_id)
#            if mc_reply_in_1h.get(key) is None:
#                mq_buzz_po_reply_new(user_id, rid)
#                mc_reply_in_1h.set(key, True, 3600)

        return id
Пример #9
0
    def reply_new(self, user, txt, state=STATE_ACTIVE, create_time=None):
        from zsite import user_can_reply
        user_id = user.id
        cid = self.cid
        if cid not in (CID_SITE, CID_COM):
            if not user_can_reply(user):
                return
        if is_spammer(user_id):
            return

        txt = txt.rstrip()
        rid = self.id

        if not txt or is_same_post(user_id, cid, rid, txt, state):
            return

        id = gid()
        if not create_time:
            create_time = int(time())
        txt_new(id, txt)
        cursor = self.reply_cursor
        cursor.execute(
            'insert into reply (id,cid,create_time,state,rid,user_id) values (%s,%s,%s,%%s,%%s,%%s)'
            % (
                id,
                cid,
                create_time,
            ), (state, rid, user_id))
        cursor.connection.commit()
        mc_flush_reply_id_list(cid, rid)

        #            key = '%s_%s' % (rid, user_id)
        #            if mc_reply_in_1h.get(key) is None:
        #                mq_buzz_po_reply_new(user_id, rid)
        #                mc_reply_in_1h.set(key, True, 3600)

        return id
Пример #10
0
def _follow_new(from_id, to_id):
    if follow_get(from_id, to_id):
        return True
    if from_id == to_id:
        return
    to = Zsite.mc_get(to_id)
    if not to:
        return
    if follow_get(from_id, to_id):
        return
    cid = to.cid
    id = gid()
    follow_cursor.execute(
        'insert into follow (id, from_id, to_id, cid) values (%s,%s,%s,%s)',
        (id, from_id, to_id, cid)
    )
    follow_cursor.connection.commit()
    mc_flush(from_id, to_id, cid)
    if cid == CID_USER:
        from model.autocomplete_user import autocomplete_user
        autocomplete_user.rank_update(
            to_id, follow_count_by_to_id(to_id)
        )
    return True
Пример #11
0
def buzz_sys_htm(htm, seq=0):
    id = gid()
    bs = BuzzSys(id=id, htm=htm, seq=seq)
    bs.save()
    if seq:
        mc_buzz_sys_init_id_list.delete('')
Пример #12
0
def buzz_sys_htm(htm, seq=0):
    id = gid()
    bs = BuzzSys(id=id, htm=htm, seq=seq)
    bs.save()
    if seq:
        mc_buzz_sys_init_id_list.delete('')
Пример #13
0
 def new(name):
     id = gid()
     o = Ob(dict(id=id, name=str(name), ico=''))
     o.save()
     return id
Пример #14
0
 def new(name):
     id = gid()
     o = Ob(dict(id=id, name=str(name), ico=''))
     o.save()
     return id
Пример #15
0
 def new(name, cid=0):
     id = gid()
     o = Ob(dict(id=id, name=str(name), ico='', cid=int(cid)))
     o.save()
     return o