示例#1
0
文件: mpost.py 项目: Sijiu/TorCMS
 def get_by_wiki(self, citiao):
     tt = CabPost.select().where(CabPost.title == citiao).count()
     if tt == 0:
         return None
     else:
         self.update_view_count(citiao)
         return CabPost.get(CabPost.title == citiao)
示例#2
0
 def get_by_wiki(self, citiao):
     tt = CabPost.select().where(CabPost.title == citiao).count()
     if tt == 0:
         return None
     else:
         self.update_view_count(citiao)
         return CabPost.get(CabPost.title == citiao)
示例#3
0
文件: mpost.py 项目: Sijiu/TorCMS
    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
示例#4
0
文件: mpost.py 项目: Elenw/TorCMS
    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
示例#5
0
文件: mpost.py 项目: Sijiu/TorCMS
 def query_cat_random(self, cat_id, num=6):
     if cat_id == '':
         return self.query_random(num)
     if config.dbtype == 1 or config.dbtype == 3:
         return CabPost.select().join(CabPost2Catalog).where(CabPost2Catalog.catalog == cat_id).order_by(
             peewee.fn.Random()).limit(num)
     elif config.dbtype == 2:
         return CabPost.select().join(CabPost2Catalog).where(CabPost2Catalog.catalog == cat_id).order_by(
             peewee.fn.Rand()).limit(num)
示例#6
0
 def query_cat_random(self, cat_id, num=6):
     if cat_id == '':
         return self.query_random(num)
     if config.dbtype == 1 or config.dbtype == 3:
         return CabPost.select().join(CabPost2Catalog).where(
             CabPost2Catalog.catalog == cat_id).order_by(
                 peewee.fn.Random()).limit(num)
     elif config.dbtype == 2:
         return CabPost.select().join(CabPost2Catalog).where(
             CabPost2Catalog.catalog == cat_id).order_by(
                 peewee.fn.Rand()).limit(num)
示例#7
0
文件: mpost.py 项目: Sijiu/TorCMS
 def get_previous_record(self, in_uid):
     current_rec = self.get_by_id(in_uid)
     query = CabPost.select().where(CabPost.time_update > current_rec.time_update).order_by(CabPost.time_update)
     if query.count() == 0:
         return None
     else:
         return query.get()
示例#8
0
文件: mpost.py 项目: Elenw/TorCMS
    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)
示例#9
0
文件: mpost.py 项目: Sijiu/TorCMS
 def update_view_count_by_uid(self, uid):
     entry = CabPost.update(view_count=CabPost.view_count + 1).where(CabPost.uid == uid)
     try:
         entry.execute()
         return True
     except:
         return False
示例#10
0
 def update_view_count_by_uid(self, uid):
     entry = CabPost.update(view_count=CabPost.view_count +
                            1).where(CabPost.uid == uid)
     try:
         entry.execute()
         return True
     except:
         return False
示例#11
0
 def get_previous_record(self, in_uid):
     current_rec = self.get_by_id(in_uid)
     query = CabPost.select().where(
         CabPost.time_update > current_rec.time_update).order_by(
             CabPost.time_update)
     if query.count() == 0:
         return None
     else:
         return query.get()
示例#12
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)
示例#13
0
 def query_most_pic(self, num):
     return CabPost.select().where(CabPost.logo != "").order_by(
         CabPost.view_count.desc()).limit(num)
示例#14
0
文件: mpost.py 项目: Sijiu/TorCMS
 def query_dated(self, num=8):
     return CabPost.select().order_by(CabPost.time_update.asc()).limit(num)
示例#15
0
 def query_cat_recent(self, cat_id, num=8):
     return CabPost.select().join(CabPost2Catalog).where(
         CabPost2Catalog.catalog == cat_id).order_by(
             CabPost.time_update.desc()).limit(num)
示例#16
0
文件: mpost.py 项目: Sijiu/TorCMS
 def update_keywords(self, uid, inkeywords):
     entry = CabPost.update(keywords=inkeywords).where(CabPost.uid == uid)
     entry.execute()
示例#17
0
文件: mpost.py 项目: Sijiu/TorCMS
 def query_cat_by_pager(self, cat_str, cureent):
     tt = CabPost.select().where(CabPost.id_cats.contains(str(cat_str))).order_by(
         CabPost.time_update.desc()).paginate(cureent, config.page_num)
     return tt
示例#18
0
文件: mpost.py 项目: Sijiu/TorCMS
 def update_view_count(self, citiao):
     entry = CabPost.update(view_count=CabPost.view_count + 1).where(CabPost.title == citiao)
     entry.execute()
示例#19
0
 def query_cat_by_pager(self, cat_str, cureent):
     tt = CabPost.select().where(CabPost.id_cats.contains(
         str(cat_str))).order_by(CabPost.time_update.desc()).paginate(
             cureent, config.page_num)
     return tt
示例#20
0
文件: mpost.py 项目: Sijiu/TorCMS
 def query_most(self, num=8):
     return CabPost.select().order_by(CabPost.view_count.desc()).limit(num)
示例#21
0
 def update_keywords(self, uid, inkeywords):
     entry = CabPost.update(keywords=inkeywords).where(CabPost.uid == uid)
     entry.execute()
示例#22
0
文件: mpost.py 项目: Sijiu/TorCMS
 def delete_last_post(self):
     # Todo: delete
     query = CabPost.select().order_by(CabPost.time_update.desc()).limit(1).get()
     self.delete(query.uid)
示例#23
0
文件: mpost.py 项目: Sijiu/TorCMS
 def get_num_by_cat(self, cat_str):
     return CabPost.select().where(CabPost.id_cats.contains(',{0},'.format(cat_str))).count()
示例#24
0
 def update_view_count(self, citiao):
     entry = CabPost.update(view_count=CabPost.view_count +
                            1).where(CabPost.title == citiao)
     entry.execute()
示例#25
0
 def __init__(self):
     self.tab = CabPost
     try:
         CabPost.create_table()
     except:
         pass
示例#26
0
文件: mpost.py 项目: Sijiu/TorCMS
 def __init__(self):
     self.tab = CabPost
     try:
         CabPost.create_table()
     except:
         pass
示例#27
0
文件: mpost.py 项目: Sijiu/TorCMS
 def query_cat_recent(self, cat_id, num=8):
     return CabPost.select().join(CabPost2Catalog).where(CabPost2Catalog.catalog == cat_id).order_by(
         CabPost.time_update.desc()).limit(num)
示例#28
0
 def get_num_by_cat(self, cat_str):
     return CabPost.select().where(
         CabPost.id_cats.contains(',{0},'.format(cat_str))).count()
示例#29
0
 def query_most(self, num=8):
     return CabPost.select().order_by(CabPost.view_count.desc()).limit(num)
示例#30
0
文件: mpost.py 项目: Sijiu/TorCMS
 def query_keywords_empty(self):
     return CabPost.select().where(CabPost.keywords == '')
示例#31
0
 def query_keywords_empty(self):
     return CabPost.select().where(CabPost.keywords == '')
示例#32
0
文件: mpost.py 项目: Sijiu/TorCMS
 def query_most_pic(self, num):
     return CabPost.select().where(CabPost.logo != "").order_by(CabPost.view_count.desc()).limit(num)
示例#33
0
 def query_dated(self, num=8):
     return CabPost.select().order_by(CabPost.time_update.asc()).limit(num)