Beispiel #1
0
    def modify_meta(uid, data_dic, extinfo={}):
        '''
        手工修改的。
        :param uid:
        :param data_dic:
        :return:
        '''
        title = data_dic['title'].strip()
        if len(title) < 2:
            return False

        cur_info = MPost.get_by_uid(uid)
        if cur_info:
            ##############################
            if DB_CFG['kind'] == 's':
                entry = g_Post.update(
                    title=title,
                    user_name=data_dic['user_name'],
                    keywords='',
                    time_create=tools.timestamp(),
                    time_update=tools.timestamp(),
                    date=datetime.now(),
                    cnt_md=data_dic['cnt_md'],
                    logo=data_dic['logo'],
                    order=data_dic['order'],
                    cnt_html=tools.markdown2html(data_dic['cnt_md']),
                    valid=data_dic['valid'],

                ).where(g_Post.uid == uid)
                entry.execute()

            else:
                cur_extinfo = cur_info.extinfo
                # Update the extinfo, Not replace
                for key in extinfo:
                    cur_extinfo[key] = extinfo[key]

                entry = g_Post.update(
                    title=title,
                    user_name=data_dic['user_name'],
                    keywords='',
                    time_create=tools.timestamp(),
                    time_update=tools.timestamp(),
                    date=datetime.now(),
                    cnt_md=data_dic['cnt_md'],
                    logo=data_dic['logo'],
                    order=data_dic['order'] if 'order' in data_dic else '',
                    cnt_html=tools.markdown2html(data_dic['cnt_md']),
                    extinfo=cur_extinfo,
                    valid=data_dic['valid'],

                ).where(g_Post.uid == uid)
                entry.execute()
        else:
            return MPost.add_meta(uid, data_dic, extinfo)
        return uid
Beispiel #2
0
    def modify_meta(uid, data_dic, extinfo=None):
        '''
        update meta of the rec.
        '''
        if extinfo is None:
            extinfo = {}
        title = data_dic['title'].strip()
        if len(title) < 2:
            return False

        cur_info = MPost.get_by_uid(uid)
        if cur_info:
            # ToDo: should not do this. Not for 's'
            if DB_CFG['kind'] == 's':
                entry = TabPost.update(
                    title=title,
                    user_name=data_dic['user_name'],
                    keywords='',
                    time_update=tools.timestamp(),
                    date=datetime.now(),
                    cnt_md=data_dic['cnt_md'],
                    memo=data_dic['memo'] if 'memo' in data_dic else '',
                    logo=data_dic['logo'],
                    order=data_dic['order'],
                    cnt_html=tools.markdown2html(data_dic['cnt_md']),
                    valid=data_dic['valid']
                ).where(TabPost.uid == uid)
                entry.execute()
            else:
                cur_extinfo = cur_info.extinfo
                # Update the extinfo, Not replace
                for key in extinfo:
                    cur_extinfo[key] = extinfo[key]

                entry = TabPost.update(
                    title=title,
                    user_name=data_dic['user_name'],
                    keywords='',
                    time_update=tools.timestamp(),
                    date=datetime.now(),
                    cnt_md=data_dic['cnt_md'],
                    memo=data_dic['memo'] if 'memo' in data_dic else '',
                    logo=data_dic['logo'],
                    order=data_dic['order'] if 'order' in data_dic else '',
                    cnt_html=tools.markdown2html(data_dic['cnt_md']),
                    extinfo=cur_extinfo,
                    valid=data_dic['valid']
                ).where(TabPost.uid == uid)
                entry.execute()
        else:
            return MPost.add_meta(uid, data_dic, extinfo)
        return uid
Beispiel #3
0
    def modify_meta(self, uid, data_dic, extinfo={}):
        '''
        手工修改的。
        :param uid:
        :param data_dic:
        :return:
        '''
        cur_info = self.get_by_uid(uid)
        if cur_info:
            entry = self.tab_app.update(
                title=data_dic['title'][0],
                keywords= ','.join([x.strip() for x in data_dic['keywords'][0].split(',')]),
                desc=data_dic['desc'][0],
                update_time=int(time.time()),
                date=datetime.now(),
                cnt_md=data_dic['cnt_md'][0],
                cnt_html=tools.markdown2html(data_dic['cnt_md'][0]),
                # lat=data_dic['lat'][0],
                # lon=data_dic['lon'][0],
                # zoom_max=data_dic['zoom_max'][0],
                # zoom_min=data_dic['zoom_min'][0],
                # zoom_current=data_dic['zoom_current'][0],
                extinfo=extinfo

            ).where(self.tab_app.uid == uid)
            entry.execute()
        else:

            entry = self.add_meta(uid, data_dic, extinfo)
            return entry
        return (uid)
Beispiel #4
0
    def modify_meta(self, uid, data_dic, extinfo={}):
        '''
        手工修改的。
        :param uid:
        :param data_dic:
        :return:
        '''
        if len(data_dic['title'][0].strip()) == 0:
            return False
        cur_info = self.get_by_uid(uid)
        if cur_info:
            cur_extinfo = cur_info.extinfo
            # Update the extinfo, Not replace
            for key in extinfo:
                cur_extinfo[key] = extinfo[key]
            entry = self.tab_app.update(
                title=data_dic['title'][0],
                keywords=','.join([x.strip() for x in data_dic['keywords'][0].strip().strip(',').split(',')]),
                update_time=int(time.time()),
                date=datetime.now(),
                cnt_md=data_dic['cnt_md'][0],
                logo=data_dic['logo'][0],
                cnt_html=tools.markdown2html(data_dic['cnt_md'][0]),
                extinfo=cur_extinfo
            ).where(self.tab_app.uid == uid)
            entry.execute()
        else:

            entry = self.add_meta(uid, data_dic, extinfo)
            return entry
        return (uid)
Beispiel #5
0
    def insert_data(self, id_post, post_data):
        title = post_data['title'][0].strip()
        if len(title) < 2:
            return False

        if len(post_data['title'][0].strip()) == 0:
            return False

        cur_rec = self.get_by_id(id_post)
        if cur_rec:
            return (False)

        entry = CabPost.create(
            title=title,
            date=datetime.datetime.now(),
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
            uid=id_post,
            time_create=time.time(),
            user_name=post_data['user_name'],
            time_update=time.time(),
            view_count=1,
            logo=post_data['logo'][0],
            keywords=post_data['keywords'][0],
        )
        return (entry.uid)
Beispiel #6
0
    def __create_rec(*args, **kwargs):
        '''
        Create the record.
        '''
        uid = args[0]
        kind = args[1]
        post_data = kwargs['post_data']

        try:
            TabWiki.create(
                uid=uid,
                title=post_data['title'].strip(),
                date=datetime.datetime.now(),
                cnt_html=tools.markdown2html(post_data['cnt_md']),
                time_create=tools.timestamp(),
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md']),
                time_update=tools.timestamp(),
                view_count=1,
                kind=kind,  # 1 for wiki,  2 for page
            )
            return True
        except Exception as err:
            print(repr(err))
            return False
Beispiel #7
0
    def modify_meta(self, uid, data_dic, extinfo={}):
        '''
        手工修改的。
        :param uid:
        :param data_dic:
        :return:
        '''
        if len(data_dic['title'][0].strip()) == 0:
            return False
        cur_info = self.get_by_uid(uid)
        if cur_info:
            cur_extinfo = cur_info.extinfo
            # Update the extinfo, Not replace
            for key in extinfo:
                cur_extinfo[key] = extinfo[key]
            entry = self.tab_app.update(
                title=data_dic['title'][0],
                keywords=','.join([
                    x.strip() for x in data_dic['keywords'][0].strip().strip(
                        ',').split(',')
                ]),
                update_time=int(time.time()),
                date=datetime.now(),
                cnt_md=data_dic['cnt_md'][0],
                logo=data_dic['logo'][0],
                cnt_html=tools.markdown2html(data_dic['cnt_md'][0]),
                extinfo=cur_extinfo).where(self.tab_app.uid == uid)
            entry.execute()
        else:

            entry = self.add_meta(uid, data_dic, extinfo)
            return entry
        return (uid)
Beispiel #8
0
    def update(self, uid, post_data, update_time=False):

        cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        try:
            if update_time:
                entry2 = CabPost.update(
                    time_update=time.time()
                ).where(CabPost.uid == uid)
                entry2.execute()
        except:
            pass

        try:
            entry = CabPost.update(
                title=post_data['title'][0],
                cnt_html=cnt_html,
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                logo=post_data['logo'][0],
                keywords=post_data['keywords'][0],
            ).where(CabPost.uid == uid)
            entry.execute()
        except:
            return False
Beispiel #9
0
    def update(uid, post_data, update_time=False):
        '''
        update the infor.
        '''

        title = post_data['title'].strip()
        if len(title) < 2:
            return False
        cnt_html = tools.markdown2html(post_data['cnt_md'])
        try:
            if update_time:
                entry2 = TabPost.update(
                    date=datetime.now(),
                    time_create=tools.timestamp()).where(TabPost.uid == uid)
                entry2.execute()
        except:
            pass
        cur_rec = MPost.get_by_uid(uid)

        entry = TabPost.update(
            title=title,
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'].strip()),
            memo=post_data['memo'] if 'memo' in post_data else '',
            cnt_html=cnt_html,
            logo=post_data['logo'],
            order=post_data['order'] if 'order' in post_data else '',
            keywords=post_data['keywords'] if 'keywords' in post_data else '',
            kind=post_data['kind'] if 'kind' in post_data else 1,
            extinfo=post_data['extinfo']
            if 'extinfo' in post_data else cur_rec.extinfo,
            time_update=tools.timestamp(),
            valid=1).where(TabPost.uid == uid)
        entry.execute()
Beispiel #10
0
    def update(self, uid, post_data, update_time=False):
        title = post_data['title'][0].strip()
        if len(title) < 2:
            return False
        cnt_html = tools.markdown2html(post_data['cnt_md'][0])
        try:
            if update_time:
                entry2 = CabPost.update(time_update=time.time()).where(
                    CabPost.uid == uid)
                entry2.execute()
        except:
            pass

        try:
            entry = CabPost.update(
                title=title,
                cnt_html=cnt_html,
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                logo=post_data['logo'][0],
                keywords=post_data['keywords'][0],
            ).where(CabPost.uid == uid)
            entry.execute()
        except:
            return False
Beispiel #11
0
    def create_post(post_uid, post_data):
        '''
        create the post.
        '''
        title = post_data['title'].strip()
        if len(title) < 2:
            return False

        cur_rec = MPost.get_by_uid(post_uid)
        if cur_rec:
            return False

        entry = TabPost.create(
            title=title,
            date=datetime.now(),
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'].strip()),
            cnt_html=tools.markdown2html(post_data['cnt_md']),
            uid=post_uid,
            time_create=(post_data['time_create']
                         if 'time_create' in post_data else tools.timestamp()),
            time_update=(post_data['time_update']
                         if 'time_update' in post_data else tools.timestamp()),
            user_name=post_data['user_name'],
            view_count=post_data['view_count']
            if 'view_count' in post_data else 1,
            logo=post_data['logo'],
            memo=post_data['memo'] if 'memo' in post_data else '',
            order=post_data['order'] if 'order' in post_data else '',
            keywords=post_data['keywords'] if 'keywords' in post_data else '',
            extinfo=post_data['extinfo'] if 'extinfo' in post_data else {},
            kind=post_data['kind'] if 'kind' in post_data else '1',
            valid=1)
        return entry.uid
Beispiel #12
0
 def add_meta(uid, data_dic, extinfo={}):
     if len(uid) < 4:
         return False
     title = data_dic['title'].strip()
     if len(title) < 2:
         return False
     g_Post.create(
         uid=uid,
         title=title,
         keywords=','.join(
             [x.strip() for x in data_dic['keywords'].split(',')]),
         time_create=tools.timestamp(),
         time_update=tools.timestamp(),
         create_time=tools.timestamp(),
         date=datetime.now(),
         cnt_md=data_dic['cnt_md'].strip(),
         logo=data_dic['logo'].strip(),
         cnt_html=tools.markdown2html(data_dic['cnt_md']),
         view_count=0,
         extinfo=extinfo,
         user_name=data_dic['user_name'],
         valid=data_dic['valid'] if 'valid' in data_dic else 1,
         kind=data_dic['kind'],
     )
     return uid
Beispiel #13
0
    def insert_data(self, post_data):
        title = post_data['title'][0].strip()
        if len(title) < 2:
            return False

        slug = post_data['slug'][0]
        uu = self.get_by_slug(slug)
        if uu is None:
            pass
        else:
            return (False)

        try:
            CabPage.create(
                title=title,
                date=datetime.datetime.now(),
                slug=slug,
                cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
                time_create=time.time(),
                id_user=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                time_update=time.time(),
                view_count=1,
            )
            return slug
        except:
            return ''
Beispiel #14
0
    def insert_data(self, post_data):
        if len(post_data['title'][0].strip()) == 0:
            return False
        slug = post_data['slug'][0]
        uu = self.get_by_slug(slug)
        if uu is None:
            pass
        else:
            return (False)

        try:
            CabPage.create(
                title=post_data['title'][0],
                date=datetime.datetime.now(),
                slug=slug,
                cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
                time_create=time.time(),
                id_user= post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                time_update=time.time(),
                view_count=1,
            )
            return slug
        except:
            return ''
Beispiel #15
0
    def update(self, uid, post_data, update_time=False):
        title = post_data['title'].strip()
        if len(title) < 2:
            return False
        cnt_html = tools.markdown2html(post_data['cnt_md'])
        try:
            if update_time:
                entry2 = g_Post.update(
                    date=datetime.datetime.now(),
                    time_create  = tools.timestamp(),
                ).where(g_Post.uid == uid)
                entry2.execute()
        except:
            pass
        cur_rec = self.get_by_id(uid)

        entry = g_Post.update(
            title=title,
            cnt_html=cnt_html,
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'].strip()),
            logo=post_data['logo'],
            keywords=post_data['keywords'] if 'keywords' in post_data else '',
            kind=post_data['kind'] if 'kind' in post_data else 1,
            extinfo=post_data['extinfo'] if 'extinfo' in post_data else cur_rec.extinfo,
            time_update= tools.timestamp(),
            valid=1,
        ).where(g_Post.uid == uid)
        entry.execute()
Beispiel #16
0
    def insert_data(self, post_data):
        title = post_data['title'].strip()
        if len(title) < 2:
            return False

        uu = self.get_by_wiki(title)
        if uu:
            self.update(uu.uid, post_data)
            return

        cnt_html = tools.markdown2html(post_data['cnt_md'])

        entry = self.tab.create(
            # No page slug should startswith '_'
            uid=post_data['uid'] if 'uid' in post_data else '_' +
            tools.get_uu8d(),
            title=title,
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            time_create=post_data['time_create']
            if 'time_craete' in post_data else tools.timestamp(),
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md']),
            time_update=tools.timestamp(),
            view_count=1,
            kind=post_data['kind'] if 'kind' in post_data else '1',
        )
        return (entry.uid)
Beispiel #17
0
    def insert_data(self, id_post, post_data):
        title = post_data['title'].strip()
        if len(title) < 2:
            return False

        cur_rec = self.get_by_id(id_post)
        if cur_rec:
            return (False)

        entry = g_Post.create(
            title=title,
            date=datetime.datetime.now(),
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md']),
            cnt_html=tools.markdown2html(post_data['cnt_md']),
            uid=id_post,
            time_create=post_data['time_create'] if 'time_create' in post_data else tools.timestamp(),
            time_update=post_data['time_update'] if 'time_update' in post_data else tools.timestamp(),
            user_name=post_data['user_name'],
            view_count=post_data['view_count'] if 'view_count' in post_data else 1,
            logo=post_data['logo'],
            keywords=post_data['keywords'] if 'keywords' in post_data else '',
            extinfo=post_data['extinfo'] if 'extinfo' in post_data else {},
            kind=post_data['kind'] if 'kind' in post_data else '1',
            valid=1,
        )
        return (entry.uid)
Beispiel #18
0
    def insert_data(self, post_data):
        title = post_data['title'].strip()
        if len(title) < 2:
            return False

        slug = post_data['slug']
        uu = self.get_by_uid(slug)
        if uu is None:
            pass
        else:
            return (False)

        try:
            g_Wiki.create(
                title=title,
                date=datetime.datetime.now(),
                uid=slug,
                cnt_html=tools.markdown2html(post_data['cnt_md']),
                time_create=time.time(),
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md']),
                time_update=time.time(),
                view_count=1,
                kind = '2', # 2 for page
            )
            return slug
        except:
            return ''
Beispiel #19
0
 def add_meta(uid, data_dic, extinfo=None):
     if extinfo is None:
         extinfo = {}
     if len(uid) < 4:
         return False
     title = data_dic['title'].strip()
     if len(title) < 2:
         return False
     TabPost.create(
         uid=uid,
         title=title,
         keywords='',
         time_create=tools.timestamp(),
         time_update=tools.timestamp(),
         create_time=tools.timestamp(),
         date=datetime.now(),
         cnt_md=data_dic['cnt_md'].strip(),
         memo=data_dic['memo'] if 'memo' in data_dic else '',
         logo=data_dic['logo'].strip(),
         order=data_dic['order'] if 'order' in data_dic else '',
         cnt_html=tools.markdown2html(data_dic['cnt_md']),
         view_count=0,
         extinfo=extinfo,
         user_name=data_dic['user_name'],
         valid=data_dic['valid'] if 'valid' in data_dic else 1,
         kind=data_dic['kind'],
     )
     return uid
Beispiel #20
0
 def update_cnt(uid, post_data):
     entry = TabWiki.update(
         cnt_html=tools.markdown2html(post_data['cnt_md']),
         user_name=post_data['user_name'],
         cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md']),
         time_update=tools.timestamp(),
     ).where(TabWiki.uid == uid)
     entry.execute()
Beispiel #21
0
    def update_cnt(uid, post_data):
        '''
        update content.
        '''

        entry = TabPost.update(
            cnt_html=tools.markdown2html(post_data['cnt_md']),
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'].strip()),
            time_update=tools.timestamp()).where(TabPost.uid == uid)
        entry.execute()
Beispiel #22
0
 def update(self, slug, post_data):
     if len(post_data['title'][0].strip()) == 0:
         return False
     entry = CabPage.update(
         title=post_data['title'][0],
         date=datetime.datetime.now(),
         cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
         cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
         time_update=time.time(),
     ).where(CabPage.slug == slug)
     entry.execute()
Beispiel #23
0
 def update(self, slug, post_data):
     if len(post_data['title'][0].strip()) == 0:
         return False
     entry = CabPage.update(
         title=post_data['title'][0],
         date=datetime.datetime.now(),
         cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
         cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
         time_update=time.time(),
     ).where(CabPage.slug == slug)
     entry.execute()
Beispiel #24
0
    def update(uid, post_data, update_time=True):
        '''
        参数 `update_time` , 是否更新时间。对于导入的数据,有时不需要更新。
        '''

        title = post_data['title'].strip()
        if len(title) < 2:
            return False
        cnt_html = tools.markdown2html(post_data['cnt_md'])
        # try:
        #     if update_time:
        #         entry2 = TabPost.update(
        #             date=datetime.now(),
        #             time_create=tools.timestamp()
        #         ).where(TabPost.uid == uid)
        #         entry2.execute()
        # except:
        #     pass
        cur_rec = MPost.get_by_uid(uid)

        if update_time:
            entry = TabPost.update(
                title=title,
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(
                    post_data['cnt_md'].strip()),
                memo=post_data['memo'] if 'memo' in post_data else '',
                cnt_html=cnt_html,
                logo=post_data['logo'],
                order=post_data['order'] if 'order' in post_data else '',
                keywords=post_data['keywords']
                if 'keywords' in post_data else '',
                kind=post_data['kind'] if 'kind' in post_data else 1,
                extinfo=post_data['extinfo']
                if 'extinfo' in post_data else cur_rec.extinfo,
                time_update=tools.timestamp(),
                valid=post_data.get('valid', 1)).where(TabPost.uid == uid)
        else:
            entry = TabPost.update(
                title=title,
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(
                    post_data['cnt_md'].strip()),
                memo=post_data['memo'] if 'memo' in post_data else '',
                cnt_html=cnt_html,
                logo=post_data['logo'],
                order=post_data['order'] if 'order' in post_data else '',
                keywords=post_data['keywords']
                if 'keywords' in post_data else '',
                kind=post_data['kind'] if 'kind' in post_data else 1,
                extinfo=post_data['extinfo']
                if 'extinfo' in post_data else cur_rec.extinfo,
                valid=post_data.get('valid', 1)).where(TabPost.uid == uid)
        entry.execute()
Beispiel #25
0
 def update(self, uid, post_data, update_time=False):
     cnt_html = tools.markdown2html(post_data['cnt_md'][0])
     entry = CabReply.update(
         title=post_data['title'][0],
         date=datetime.datetime.now(),
         cnt_html=cnt_html,
         user_name=post_data['user_name'],
         cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
         time_update=tools.timestamp(),
         logo=post_data['logo'][0],
         keywords=post_data['keywords'][0],
     ).where(CabReply.uid == uid)
     entry.execute()
Beispiel #26
0
 def modify_by_uid(pid, post_data):
     rec = MReply.get_by_uid(pid)
     if rec:
         entry = TabReply.update(
             user_name=post_data['user_name'],
             user_id=post_data['user_id'],
             category=post_data['category'],
             timestamp=tools.timestamp(),
             date=datetime.datetime.now(),
             cnt_md=tornado.escape.xhtml_escape(post_data['cnt_reply']),
             cnt_html=tools.markdown2html(post_data['cnt_reply']),
         ).where(TabReply.uid == pid)
         entry.execute()
         return pid
Beispiel #27
0
    def update(self, uid, post_data):


        cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabWiki.update(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=tools.timestamp(),
        ).where(CabWiki.uid == uid)
        entry.execute()
Beispiel #28
0
    def update_cnt(uid, post_data):
        '''
        :param uid:
        :param post_data:
        :return:
        '''

        entry = g_Post.update(
            cnt_html=tools.markdown2html(post_data['cnt_md']),
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'].strip()),
            time_update=tools.timestamp(),
        ).where(g_Post.uid == uid)
        entry.execute()
Beispiel #29
0
    def update(self, slug, post_data):
        title = post_data['title'].strip()
        if len(title) < 2:
            return False

        entry = g_Wiki.update(
            title=title,
            date=datetime.datetime.now(),
            cnt_html=tools.markdown2html(post_data['cnt_md']),
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md']),
            time_update=time.time(),
            kind = '2',
        ).where(g_Wiki.uid == slug)
        entry.execute()
Beispiel #30
0
    def update(uid, post_data):
        title = post_data['title'].strip()
        if len(title) < 2:
            return False

        cnt_html = tools.markdown2html(post_data['cnt_md'])

        entry = TabWiki.update(
            title=title,
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md']),
            time_update=tools.timestamp()).where(TabWiki.uid == uid)
        entry.execute()
Beispiel #31
0
 def add_meta(self, uid, data_dic, extinfo={}):
     if len(data_dic['title'][0].strip()) == 0:
         return False
     entry = self.tab_app.create(
         uid=uid,
         title=data_dic['title'][0],
         keywords=','.join([x.strip() for x in data_dic['keywords'][0].split(',')]),
         update_time=int(time.time()),
         date=datetime.now(),
         cnt_md=data_dic['cnt_md'][0],
         logo=data_dic['logo'][0],
         cnt_html=tools.markdown2html(data_dic['cnt_md'][0]),
         extinfo=extinfo,
         user_name=data_dic['user_name'],
     )
Beispiel #32
0
    def insert_data(self, post_data):
        uid = tools.get_uuid()

        g_Reply.create(
            uid=uid,
            post_id=post_data['post_id'],
            user_name=post_data['user_name'],
            user_id=post_data['user_id'],
            timestamp=tools.timestamp(),
            date=datetime.datetime.now(),
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_reply']),
            cnt_html=tools.markdown2html(post_data['cnt_reply']),
            vote=0,
        )
        return (uid)
Beispiel #33
0
 def insert_data(self, post_data):
     uid = tools.get_uuid()
     try:
         CabReply.create(
             uid=uid,
             user_name=post_data['user_name'],
             create_user_id=post_data['user_id'],
             timestamp=tools.timestamp(),
             date=datetime.datetime.now(),
             cnt_md=post_data['cnt_md'][0],
             cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
             vote=0,
         )
         return (uid)
     except:
         return False
Beispiel #34
0
 def add_meta(self, uid, data_dic, extinfo={}):
     if len(data_dic['title'][0].strip()) == 0:
         return False
     entry = self.tab_app.create(
         uid=uid,
         title=data_dic['title'][0],
         keywords=','.join(
             [x.strip() for x in data_dic['keywords'][0].split(',')]),
         update_time=int(time.time()),
         date=datetime.now(),
         cnt_md=data_dic['cnt_md'][0],
         logo=data_dic['logo'][0],
         cnt_html=tools.markdown2html(data_dic['cnt_md'][0]),
         extinfo=extinfo,
         user_name=data_dic['user_name'],
     )
Beispiel #35
0
 def create_reply(post_data):
     '''
     Create the reply.
     '''
     uid = tools.get_uuid()
     TabReply.create(uid=uid,
                     post_id=post_data['post_id'],
                     user_name=post_data['user_name'],
                     user_id=post_data['user_id'],
                     timestamp=tools.timestamp(),
                     date=datetime.datetime.now(),
                     cnt_md=tornado.escape.xhtml_escape(
                         post_data['cnt_reply']),
                     cnt_html=tools.markdown2html(post_data['cnt_reply']),
                     vote=0)
     return uid
Beispiel #36
0
    def insert_data(self, post_data):

        uid = tools.get_uuid()
        try:
            CabReply.create(
                uid=uid,
                user_name=post_data['user_name'],
                create_user_id=post_data['user_id'],
                timestamp=tools.timestamp(),
                date=datetime.datetime.now(),
                cnt_md=post_data['cnt_md'][0],
                cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
                vote=0,
            )
            return (uid)
        except:
            return False
Beispiel #37
0
    def add_meta(self, uid,  data_dic, extinfo = {}):

            entry = self.tab_app.create(
                uid=uid,
                title=data_dic['title'][0],
                keywords= ','.join([x.strip() for x in data_dic['keywords'][0].split(',')]),
                desc=data_dic['desc'][0],
                update_time=int(time.time()),
                date=datetime.now(),
                cnt_md=data_dic['cnt_md'][0],
                cnt_html=tools.markdown2html(data_dic['cnt_md'][0]),
                extinfo=extinfo,

                # lat=data_dic['lat'][0],
                #lon=data_dic['lon'][0],
                #zoom_max=data_dic['zoom_max'][0],
                #zoom_min=data_dic['zoom_min'][0],
                # zoom_current=data_dic['zoom_current'][0],
            )
Beispiel #38
0
    def insert_data(self, id_post, post_data):

        cur_rec = self.get_by_id(id_post)
        if cur_rec :
            return (False)

        entry = CabPost.create(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            cnt_html= tools.markdown2html(post_data['cnt_md'][0]) ,
            uid=id_post,
            time_create=time.time(),
            user_name=post_data['user_name'],
            time_update=time.time(),
            view_count=1,
            logo=post_data['logo'][0],
            keywords=post_data['keywords'][0],
        )
        return (entry.uid)
Beispiel #39
0
    def test_insert(self):
        raw_count = self.uu.get_counts()

        post_data = {
            'title': self.post_title,
            'cnt_md': '## adslkfjasdf\n lasdfkjsadf',
            'user_name': 'Tome',
            'view_count': 1,
            'logo': '/static/',
            'keywords': 'sdf',
        }
        self.uu.create_post(self.uid, post_data)
        new_count = self.uu.get_counts()

        tt = self.uu.get_by_uid(self.uid)
        assert tt.title == post_data['title']
        assert tt.cnt_md == tornado.escape.xhtml_unescape(post_data['cnt_md'])
        assert tt.cnt_html == tools.markdown2html(post_data['cnt_md'])
        assert raw_count + 1 == new_count
        self.tearDown()
Beispiel #40
0
    def insert_data(self, post_data):
        title = post_data['title'][0]
        uu = self.get_by_wiki(title)
        if uu is None:
            pass
        else:
            return (False)


        cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabWiki.create(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            uid=tools.get_uu8d(),
            time_create=tools.timestamp(),
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=tools.timestamp(),
            view_count=1,
        )
        return (entry.uid)
Beispiel #41
0
    def update(self, uid, post_data, update_time=False):

        if 'id_spec' in post_data:
            id_spec = post_data['id_spec'][0]
        else:
            id_spec = 0

        if 'src_type' in post_data and post_data['src_type'][0] == '1':
            cnt_html = tools.rst2html(post_data['cnt_md'][0])
        else:
            cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        if update_time:
            entry = CabVoter2Reply.update(
                title=post_data['title'][0],
                date=datetime.datetime.now(),
                cnt_html=cnt_html,
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                time_update=time.time(),
                id_spec=id_spec,
                logo=post_data['logo'][0],
                keywords=post_data['keywords'][0],
                src_type=post_data['src_type'][0] if ('src_type' in post_data) else 0
            ).where(CabVoter2Reply.uid == uid)
        else:
            entry = CabVoter2Reply.update(
                title=post_data['title'][0],
                cnt_html=cnt_html,
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                id_spec=id_spec,
                logo=post_data['logo'][0],
                keywords=post_data['keywords'][0],
                src_type=post_data['src_type'][0] if ('src_type' in post_data) else 0
            ).where(CabVoter2Reply.uid == uid)
        entry.execute()