def update(self, uid):
     if self.userinfo.role[0] > '0':
         pass
     else:
         return False
     post_data = self.get_post_data()
     if self.userinfo:
         post_data['user_name'] = self.userinfo.user_name
     else:
         post_data['user_name'] = ''
     cur_info = MPost.get_by_uid(uid)
     MPostHist.create_post_history(cur_info)
     MPost.update_cnt(uid, post_data)
     self.redirect('/{0}/{1}'.format(router_post[cur_info.kind], uid))
    def test_create_post_history(self):
        self.tearDown()

        p_d = {
            'title': 'qqqii',
            'cnt_md': 'qwqwqw',
            'time_create': '1999',
            'time_update': '2019',
            'user_name': 'max',
            'view_count': '1',
            'logo': 'opps',
            'memo': '',
            'order': '1',
            'kind': '1',
            'valid': 1,
        }
        MPost().add_meta(self.post_id, p_d)
        aa = MPost.get_by_uid(self.post_id)
        tf = MPostHist.create_post_history(aa, aa)
        assert tf
        His = MPostHist.query_by_postid(self.post_id)

        self.uid = His[0].uid
        assert His[0].cnt_md == p_d['cnt_md']
        self.tearDown()
Exemple #3
0
    def update(self, uid):
        '''
        in infor.
        '''

        postinfo = MPost.get_by_uid(uid)
        if postinfo.kind == self.kind:
            pass
        else:
            return False

        post_data, ext_dic = self.fetch_post_data()
        if 'gcat0' in post_data:
            pass
        else:
            return False

        if 'valid' in post_data:
            post_data['valid'] = int(post_data['valid'])
        else:
            post_data['valid'] = postinfo.valid

        ext_dic['def_uid'] = str(uid)

        cnt_old = tornado.escape.xhtml_unescape(postinfo.cnt_md).strip()
        cnt_new = post_data['cnt_md'].strip()
        if cnt_old == cnt_new:
            pass
        else:
            MPostHist.create_post_history(postinfo)

        MPost.modify_meta(uid, post_data, extinfo=ext_dic)

        self._add_download_entity(ext_dic)
        # self.update_tag(uid=uid)

        update_category(uid, post_data)
        update_label(uid, post_data)
        # self.update_label(uid)

        logger.info('post kind:' + self.kind)
        # cele_gen_whoosh.delay()
        tornado.ioloop.IOLoop.instance().add_callback(self.cele_gen_whoosh)
        self.redirect('/{0}/{1}'.format(router_post[postinfo.kind], uid))
    def update(self, uid):
        if self.userinfo.role[0] > '0':
            pass
        else:
            return False
        post_data = self.get_post_data()
        if self.userinfo:
            post_data['user_name'] = self.userinfo.user_name
        else:
            post_data['user_name'] = ''
        cur_info = MPost.get_by_uid(uid)
        cur_info.user_name = post_data['user_name']

        cnt_old = tornado.escape.xhtml_unescape(cur_info.cnt_md).strip()
        cnt_new = post_data['cnt_md'].strip()
        if cnt_old == cnt_new:
            pass
        else:
            MPostHist.create_post_history(cur_info, self.userinfo)
            MPost.update_cnt(uid, post_data)
        self.redirect('/{0}/{1}'.format(router_post[cur_info.kind], uid))
    def addHis(self, **kwargs):
        p_d = {
            'title': kwargs.get('title', 'iiiii'),
            'cnt_md': kwargs.get('cnt_md', 'grgr'),
            'time_create': kwargs.get('time_create', '1992'),
            'time_update': kwargs.get('time_update', '1996070600'),
            'user_name': kwargs.get('user_name', 'yuanyuan'),
            'view_count': kwargs.get('view_count', 1),
            'logo': kwargs.get('logo', 'prprprprpr'),
            'memo': kwargs.get('memo', ''),
            'order': kwargs.get('order', '1'),
            'keywords': kwargs.get('keywords', ''),
            'extinfo': kwargs.get('extinfo', {}),
            'kind': kwargs.get('kind', '1'),
            'valid': kwargs.get('valid', 1),
        }
        MPost().add_meta(self.post_id, p_d)
        aa = MPost.get_by_uid(self.post_id)
        MPostHist.create_post_history(aa, aa)

        His = MPostHist.query_by_postid(self.post_id)

        self.uid = His[0].uid