Esempio n. 1
0
    def post(self, id):
        id = int(id)
        txt = self.get_argument('txt', None)
        rt = self.get_argument('rt', None)
        title = self.get_argument('name', None)
        sync = self.get_argument('sync', None)
        po = RssPo.mc_get(id)
        po.txt = txt
        next = self.get_argument('next', None) or '/rss/index'
        if rt:
            po.state = RSS_RT_PO
        else:
            po.state = RSS_PRE_PO
        site = self.get_argument('site', None)
        if site:
            po.site_id = site
        if title:
            po.title = title
        po.save()

        if sync:
            site_sync_new(id)
        else:
            site_sync_rm(id)

        self.redirect(next)
def feed_new(feed):
    txt = txt_img_fetch(feed.txt)
    zsite_id = feed.zsite_id
    feed_user = user_by_feed_id_zsite_id(zsite_id, feed.rid)
    if feed_user:
        user_id = feed_user.user_id
    else:
        user_id = 0
    id = feed.id

    if user_id:
        feed_import_user_rm(user_id, id)

    zsite_id = feed.zsite_id

    is_without_author = (
        (feed.state == FEED_IMPORT_STATE_REVIEWED_WITHOUT_AUTHOR_SYNC)
        or
        (feed.state == FEED_IMPORT_STATE_REVIEWED_WITHOUT_AUTHOR)
    )

    if is_without_author:
        user_id = 0
        zsite_id = 0

    title = title_normal(feed.title)
    po = po_note_new(user_id, title, txt, zsite_id=zsite_id)

    if po:
        if not feed_user:
            feed_user_id = 0
        else:
            feed_user_id = feed_user.id

        record = PoMeta.get_or_create(id=po.id)
        record.user_id = feed_user_id
        record.url_id = url_short_id(feed.url)

        record.save()

        if not is_without_author:
            po.rid = record.id
            po.save()

        if feed.state >= FEED_IMPORT_STATE_REVIEWED_SYNC:
            site_sync_new(po.id)

        feed.state = FEED_IMPORT_STATE_POED
        feed.save()

        cid = feed.cid

        po_tag_id_list_new(po, feed.tag_id_list.split(' '), cid)
Esempio n. 3
0
def feed_new(feed):
    txt = txt_img_fetch(feed.txt)
    zsite_id = feed.zsite_id
    feed_user = user_by_feed_id_zsite_id(zsite_id, feed.rid)
    if feed_user:
        user_id = feed_user.user_id
    else:
        user_id = 0
    id = feed.id

    if user_id:
        feed_import_user_rm(user_id, id)

    zsite_id = feed.zsite_id

    is_without_author = (
        (feed.state == FEED_IMPORT_STATE_REVIEWED_WITHOUT_AUTHOR_SYNC)
        or (feed.state == FEED_IMPORT_STATE_REVIEWED_WITHOUT_AUTHOR))

    if is_without_author:
        user_id = 0
        zsite_id = 0

    title = title_normal(feed.title)
    po = po_note_new(user_id, title, txt, zsite_id=zsite_id)

    if po:
        if not feed_user:
            feed_user_id = 0
        else:
            feed_user_id = feed_user.id

        record = PoMeta.get_or_create(id=po.id)
        record.user_id = feed_user_id
        record.url_id = url_short_id(feed.url)

        record.save()

        if not is_without_author:
            po.rid = record.id
            po.save()

        if feed.state >= FEED_IMPORT_STATE_REVIEWED_SYNC:
            site_sync_new(po.id)

        feed.state = FEED_IMPORT_STATE_POED
        feed.save()

        cid = feed.cid

        po_tag_id_list_new(po, feed.tag_id_list.split(' '), cid)
Esempio n. 4
0
def _edit(broad, sync, site, po, id):
    if broad:
        from model.po_recommend import po_recommend_new
        test_po = Po.get(rid=po.id, user_id=0, state=STATE_ACTIVE)
        if not test_po:
            po_recommend_new(po.id, 0, '')
    else:
        po_show_rm(po)

    if sync:
        site_sync_new(id)
    else:
        site_sync_rm(id)

    if site:
        po.zsite_id_set(site)
Esempio n. 5
0
def _edit(broad, sync, site, po, id):
    if broad:
        from model.po_recommend import po_recommend_new

        test_po = Po.get(rid=po.id, user_id=0, state=STATE_ACTIVE)
        if not test_po:
            po_recommend_new(po.id, 0, "")
    else:
        po_show_rm(po)

    if sync:
        site_sync_new(id)
    else:
        site_sync_rm(id)

    if site:
        po.zsite_id_set(site)