Exemple #1
0
def po_post(self):
    user_id = self.current_user_id
    name = self.get_argument('name', '')
    txt = self.get_argument('txt', '', strip=False).rstrip()
    zsite = self.zsite
    cid = self.cid

    arguments = self.request.arguments

    state = None

    if cid == CID_EVENT_FEEDBACK:
        state = self.get_argument('good', None)
        zsite_id = 0
    else:
        zsite_id = zsite_id_by_zsite_user_id(zsite, user_id)


        if zsite_id:
            state = STATE_PO_ZSITE_SHOW_THEN_REVIEW
        else:
            secret = self.get_argument('secret', None)
            if secret:
                state = STATE_SECRET
            else:
                state = STATE_ACTIVE

    if state == STATE_SECRET:    
        from model.feed import feed_rm
        feed_rm(self.id)

    po = self.po_save(user_id, name, txt, state, zsite_id)


    self_id = self.id
    if po:
        po_id = po.id
    else:
        po_id = 0

    if po or self_id == 0:
        update_pic(arguments, user_id, po_id, self_id)
        mc_pic_id_list.delete(
            '%s_%s' % (user_id, self_id)
        )

    if cid == CID_NOTE and po:
        tag_id_list = self.get_arguments('tag_id_list', [])

        po_tag_new_by_autocompelte(po, tag_id_list, admin_id = user_id)

    return po
Exemple #2
0
def po_post(self):
    user_id = self.current_user_id
    name = self.get_argument('name', '')
    txt = self.get_argument('txt', '', strip=False).rstrip()
    zsite = self.zsite
    cid = self.cid

    arguments = self.request.arguments

    state = None

    if cid == CID_EVENT_FEEDBACK:
        state = self.get_argument('good', None)
        zsite_id = 0
    else:
        zsite_id = zsite_id_by_zsite_user_id(zsite, user_id)

        if zsite_id:
            state = STATE_PO_ZSITE_SHOW_THEN_REVIEW
        else:
            secret = self.get_argument('secret', None)
            if secret:
                state = STATE_SECRET
            else:
                state = STATE_ACTIVE

    if state == STATE_SECRET:
        from model.feed import feed_rm
        feed_rm(self.id)

    po = self.po_save(user_id, name, txt, state, zsite_id)

    self_id = self.id
    if po:
        po_id = po.id
    else:
        po_id = 0

    if po or self_id == 0:
        update_pic(arguments, user_id, po_id, self_id)
        mc_pic_id_list.delete('%s_%s' % (user_id, self_id))

    if cid == CID_NOTE and po:
        tag_id_list = self.get_arguments('tag_id_list', [])

        po_tag_new_by_autocompelte(po, tag_id_list, admin_id=user_id)

    return po
Exemple #3
0
    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)