コード例 #1
0
def zsite_tag_new_by_tag_id(po, tag_id=1):
    if not Tag.get(tag_id):
        tag_id = 1
    zsite_id = po.user_id
    po_id = po.id
    po_cid = po.cid

    if tag_id == 1:  #初始化
        zsite_tag_id_list_with_init(zsite_id)

    id = zsite_tag_new_by_zsite_id_tag_id(zsite_id, tag_id)
    tag_po = ZsiteTagPo.get_or_create(po_id=po_id,
                                      zsite_id=zsite_id,
                                      cid=po_cid)

    pre_tag_id = tag_po.zsite_tag_id
    tag_po.zsite_tag_id = id
    tag_po.save()

    mc_tag_by_po_id.delete('%s_%s' % (zsite_id, po_id))

    from model.po_prev_next import mc_flush
    tag_po_id = tag_po.id

    if pre_tag_id:
        mc_po_id_list_by_zsite_tag_id.delete(pre_tag_id)
        zsite_tag_cid_count.delete(pre_tag_id, po_cid)
        mc_po_id_list_by_zsite_tag_id_cid.delete('%s_%s' %
                                                 (pre_tag_id, po_cid))
        mc_flush(po, zsite_id, pre_tag_id)

    mc_po_id_list_by_zsite_tag_id.delete(id)
    mc_po_id_list_by_zsite_tag_id_cid.delete('%s_%s' % (id, po_cid))
    zsite_tag_cid_count.delete(id, po_cid)
    mc_flush(po, zsite_id, id)
コード例 #2
0
    def htm2po_by_po(self):
        if self.find_dup():
            return
        txt = self.txt.rstrip()
        if not txt:
            return

        zsite = Zsite.mc_get(self.user_id)

        if zsite.cid == CID_SITE:
            group_id = zsite.id
        else:
            group_id = self.site_id

        po = po_note_new(
            self.user_id, self.title, '', STATE_RM, group_id
        )

        if not po:
            return
        po_id = po.id

        pic_list = self.pic_list

        for seq, url in enumerate(pic_list, 1):
            img = fetch_pic(url)
            if img:
                x, y = img.size
                if x < 48 and y < 48:
                    img = None

            if img:
                po_pic_new(self.user_id, po_id, img, seq)

            else:
                txt = re.sub('\s*图:%s\s*'%seq, '', txt, re.MULTILINE)

        po.txt_set(txt)

        if group_id:
            state = STATE_PO_ZSITE_SHOW_THEN_REVIEW
        else:
            state = STATE_ACTIVE

        po.state = state
        po.save()

        if po.zsite_id != po.user_id:
            zsite_tag_new_by_tag_id(po)

        po.feed_new()

        if self.state == RSS_RT_PO:
            po_show_new(po)

        mc_flush(po, po.zsite_id)

        return po
コード例 #3
0
def zsite_tag_rm_by_po(po):
    id = po.id
    cid = po.cid
    for i in ZsiteTagPo.where(po_id=id):
        mc_flush_zsite_tag_id(i.zsite_tag_id)
        i.delete()
        from model.po_prev_next import mc_flush
        mc_flush(po, i.zsite_id, i.zsite_tag_id)
    mc_tag_by_po_id.delete('%s_%s' % (po.user_id, id))
コード例 #4
0
def zsite_tag_rm_by_po(po):
    id = po.id
    cid = po.cid
    for i in ZsiteTagPo.where(po_id=id):
        mc_flush_zsite_tag_id(i.zsite_tag_id)
        i.delete()
        from model.po_prev_next import mc_flush
        mc_flush(po, i.zsite_id, i.zsite_tag_id)
    mc_tag_by_po_id.delete('%s_%s' % (po.user_id, id))
コード例 #5
0
ファイル: rss_po.py プロジェクト: xqk/42qu_github_mirror
    def htm2po_by_po(self):
        if self.find_dup():
            return
        txt = self.txt.rstrip()
        if not txt:
            return

        zsite = Zsite.mc_get(self.user_id)

        if zsite.cid == CID_SITE:
            group_id = zsite.id
        else:
            group_id = self.site_id

        po = po_note_new(self.user_id, self.title, '', STATE_RM, group_id)

        if not po:
            return
        po_id = po.id

        pic_list = self.pic_list

        for seq, url in enumerate(pic_list, 1):
            img = fetch_pic(url)
            if img:
                x, y = img.size
                if x < 48 and y < 48:
                    img = None

            if img:
                po_pic_new(self.user_id, po_id, img, seq)

            else:
                txt = re.sub('\s*图:%s\s*' % seq, '', txt, re.MULTILINE)

        po.txt_set(txt)

        if group_id:
            state = STATE_PO_ZSITE_SHOW_THEN_REVIEW
        else:
            state = STATE_ACTIVE

        po.state = state
        po.save()

        if po.zsite_id != po.user_id:
            zsite_tag_new_by_tag_id(po)

        po.feed_new()

        if self.state == RSS_RT_PO:
            po_show_new(po)

        mc_flush(po, po.zsite_id)

        return po
コード例 #6
0
def htm2po_by_po(pre):
    txt = pre.txt.rstrip()

    if not txt:
        return

    zsite = Zsite.mc_get(pre.user_id)

    if zsite.cid == CID_SITE:
        group_id = zsite.id
    else:
        group_id = pre.site_id

    rp = RssPoId.get(rss_po_id=pre.id)
    if rp:
        po = Po.mc_get(rp.po_id)
        if po:
            po.name_ = pre.title
            po.save()
    else:
        po = po_note_new(pre.user_id, pre.title, "", STATE_RM, group_id)
        if po and zsite.cid == CID_USER:
            po.rid = pre.rss_id
            po.save()

    if not po:
        return

    po_id = po.id

    if not rp:
        rss_po_id_new(zsite, pre.id, po_id)

    txt = txt_img_fetch(txt)

    po.txt_set(txt)

    if group_id:
        state = STATE_PO_ZSITE_SHOW_THEN_REVIEW
    else:
        state = STATE_ACTIVE
    po.state = state
    po.save()

    if po.zsite_id != po.user_id:
        zsite_tag_new_by_tag_id(po)

    if pre.state == RSS_RT_PO:
        po_show_new(po)

    mc_flush(po, po.zsite_id)

    return po
コード例 #7
0
def zsite_tag_new_by_tag_id(po, tag_id=1):
    if not Tag.get(tag_id):
        tag_id = 1
    zsite_id = po.user_id
    po_id = po.id
    po_cid = po.cid

    if tag_id == 1: #初始化
        zsite_tag_id_list_with_init(zsite_id)

    id = zsite_tag_new_by_zsite_id_tag_id(zsite_id, tag_id)
    tag_po = ZsiteTagPo.get_or_create(
        po_id=po_id,
        zsite_id=zsite_id,
        cid=po_cid
    )

    pre_tag_id = tag_po.zsite_tag_id
    tag_po.zsite_tag_id = id
    tag_po.save()

    mc_tag_by_po_id.delete('%s_%s'%(zsite_id, po_id))

    from model.po_prev_next import mc_flush
    tag_po_id = tag_po.id

    if pre_tag_id:
        mc_po_id_list_by_zsite_tag_id.delete(pre_tag_id)
        zsite_tag_cid_count.delete(pre_tag_id, po_cid)
        mc_po_id_list_by_zsite_tag_id_cid.delete('%s_%s'%(pre_tag_id, po_cid))
        mc_flush(po, zsite_id, pre_tag_id)

    mc_po_id_list_by_zsite_tag_id.delete(id)
    mc_po_id_list_by_zsite_tag_id_cid.delete('%s_%s'%(id, po_cid))
    zsite_tag_cid_count.delete(id, po_cid)
    mc_flush(po, zsite_id, id)