Ejemplo n.º 1
0
    def po_save(self, user_id, name, txt, state, zsite_id):
        po = self.po
        if po is None:
            return

        cid = po.cid
        rid = po.rid
        po.zsite_id = zsite_id

        if cid == CID_WORD:
            if cnenlen(txt) > 140:
                answer_word2note(po)
                po.txt_set(txt)
            else:
                po.name_ = txt
        elif cid == CID_EVENT_FEEDBACK:
            event_joiner_state_set_by_good(user_id, rid, state)
            if txt:
                po.txt_set(txt)
        else:
            if not po.rid and name:
                po.name_ = name
            if txt:
                po.txt_set(txt)

        if cid in (CID_NOTE, CID_QUESTION, CID_ANSWER):
            if not (cid == CID_QUESTION and po.state == STATE_ACTIVE):
                po_state_set(po, state)

        po.save()
        return po
Ejemplo n.º 2
0
    def po_save(self, user_id, name, txt, state, zsite_id):
        po = self.po
        if po is None:
            return

        cid = po.cid
        rid = po.rid
        po.zsite_id = zsite_id

        if cid == CID_WORD:
            if cnenlen(txt) > 140:
                answer_word2note(po)
                po.txt_set(txt)
            else:
                po.name_ = txt
        elif cid == CID_EVENT_FEEDBACK:
            event_joiner_state_set_by_good(user_id, rid, state)
            if txt:
                po.txt_set(txt)
        else:
            if not po.rid and name:
                po.name_ = name
            if txt:
                po.txt_set(txt)



        if cid in (CID_NOTE, CID_QUESTION, CID_ANSWER):
            if not (cid == CID_QUESTION and po.state == STATE_ACTIVE):
                po_state_set(po, state)


        po.save()
        return po
Ejemplo n.º 3
0
    def _post(self, id):
        user_id = self.current_user_id

        files = self.request.files
        img = files.get('img')
        if img:
            img = img[0]['body']
        else:
            return 0

        if len(img) > 1024 * 1024 * 12:
            return 2

        img = picopen(img)
        if not img:
            return 10

        if id:
            po = Po.mc_get(id)
            if not po or po.user_id != user_id or (po.cid == CID_WORD
                                                   and po.rid == 0):
                return 0
            if po.cid == CID_WORD:
                answer_word2note(po)

        if not pic_can_add(user_id, id):
            return 16

        pic = po_pic_new(user_id, id, img)
        if not pic:
            return 14

        r = {
            'status': 0,
            'src': fs_url_jpg(219, pic.id),
            'seqid': pic.seq,
        }

        return r
Ejemplo n.º 4
0
    def _post(self, id):
        user_id = self.current_user_id

        files = self.request.files
        img = files.get('img')
        if img:
            img = img[0]['body']
        else:
            return 0

        if len(img) > 1024*1024*12:
            return 2

        img = picopen(img)
        if not img:
            return 10

        if id:
            po = Po.mc_get(id)
            if not po or po.user_id != user_id or (po.cid == CID_WORD and po.rid == 0):
                return 0
            if po.cid == CID_WORD:
                answer_word2note(po)

        if not pic_can_add(user_id, id):
            return 16

        pic = po_pic_new(user_id, id, img)
        if not pic:
            return 14

        r = {
            'status': 0,
            'src': fs_url_jpg(219, pic.id),
            'seqid': pic.seq,
        }

        return r