コード例 #1
0
    def post(self):
        result = None
        current_user_id = self.current_user_id
        txt = self.get_argument('txt', None)
        if txt:
            host = self.request.host
            zsite = zsite_by_domain(host)
            if zsite and zsite.cid == CID_SITE:
                zsite_id = zsite.id
            else:
                zsite_id = 0

            m = po_word_new(current_user_id, txt, zsite_id=zsite_id)
            if not zsite_id and m:
                c_dict = career_dict(set([current_user_id]))
                unit, title = c_dict[current_user_id]
                result = [[
                    1, zsite.name, zsite.link, unit, title,
                    pic_url_with_default(current_user_id, '219'),
                    [[
                        m.id, [], 0, 61, 0, 0, 0,
                        time.time(), None,
                        txt_withlink(txt), False
                    ]]
                ], []]
        self.finish(dumps(result))
コード例 #2
0
ファイル: po.py プロジェクト: immissile/42qu_github_mirror
    def post(self):
        result = None
        current_user_id = self.current_user_id
        txt = self.get_argument('txt', None)
        if txt:
            host = self.request.host
            zsite = zsite_by_domain(host)
            if zsite and zsite.cid == CID_SITE:
                zsite_id = zsite.id
            else:
                zsite_id = 0

            m = po_word_new(current_user_id, txt, zsite_id=zsite_id)
            if not zsite_id and m:
                c_dict = career_dict(set([current_user_id]))
                unit, title = c_dict[current_user_id]
                result = [
                    [
                        1, zsite.name, zsite.link, unit,
                        title, pic_url_with_default(current_user_id, '219'),
                        [[m.id, [], 0, 61, 0, 0, 0, time.time(), None, txt_withlink(txt), False]]
                    ],
                    []
                ]
        self.finish(dumps(result))
コード例 #3
0
ファイル: feed.py プロジェクト: xqk/42qu_github_mirror
    def get(self, id):
        id = int(id)
        if id == 0:
            id = MAXINT
        current_user_id = self.current_user_id

        result, last_id = render_feed_by_zsite_id(current_user_id, PAGE_LIMIT, id)
        result = tuple(
            (i, tuple(g)) for i, g in groupby(result, itemgetter(0))
        )
        zsite_id_set = set(
            i[0] for i in result
        )
        c_dict = career_dict(zsite_id_set)

        r = []

        if result:
            site_id_set = set()
            for zsite_id, item_list in result:
                zsite = Zsite.mc_get(zsite_id)
                t = []
                for i in item_list:
                    id = i[1]
                    cid = i[4]
                    rid = i[5]

                    site_id = i[6]
                    if site_id:
                        site_id_set.add(site_id)

                    if len(i) >= FEED_TUPLE_DEFAULT_LEN:
                        after = i[FEED_TUPLE_DEFAULT_LEN:]
                        i = i[:FEED_TUPLE_DEFAULT_LEN]
                    else:
                        after = None


                    if cid not in (CID_WORD, CID_EVENT):
                        i.extend(zsite_tag_id_tag_name_by_po_id(zsite_id, id))

                    if after:
                        i.extend(after)
                    t.append(i[1:])

                unit, title = c_dict[zsite_id]
                if zsite:
                    r.append((
                        zsite.cid,
                        zsite.name,
                        zsite.link,
                        unit,
                        title,
                        pic_url_with_default(zsite_id, '219'),
                        t
                    ))
                else:
                    print 'zsite_id', zsite_id
                    feed_rm(id)

            r.append(zsite_name_id_dict(site_id_set))
            r.append(last_id)


        result = dumps(r)

        self.finish(result)