示例#1
0
文件: mwiki.py 项目: daimon99/TorCMS
 def get_by_wiki(self, citiao):
     tt = CabWiki.select().where(CabWiki.title == citiao).count()
     if tt == 0:
         return None
     else:
         self.update_view_count(citiao)
         return CabWiki.get(CabWiki.title == citiao)
示例#2
0
 def get_by_wiki(self, citiao):
     tt = CabWiki.select().where(CabWiki.title == citiao).count()
     if tt == 0:
         return None
     else:
         self.update_view_count(citiao)
         return CabWiki.get(CabWiki.title == citiao)
示例#3
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)
        if 'id_spec' in post_data:
            id_spec = post_data['id_spec'][0]
        else:
            id_spec = 0
        if 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])

        entry = CabWiki.create(title=post_data['title'][0],
                               date=datetime.datetime.now(),
                               cnt_html=cnt_html,
                               uid=tools.get_uu8d(),
                               time_create=time.time(),
                               user_name=post_data['user_name'],
                               cnt_md=tornado.escape.xhtml_escape(
                                   post_data['cnt_md'][0]),
                               time_update=time.time(),
                               view_count=1,
                               src_type=post_data['src_type'][0])
        return (entry.uid)
示例#4
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)
        if 'id_spec' in post_data:
            id_spec = post_data['id_spec'][0]
        else:
            id_spec = 0
        if 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])

        entry = CabWiki.create(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            uid=tools.get_uu8d(),
            time_create=time.time(),
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=time.time(),
            view_count=1,
            src_type=post_data['src_type'][0]
        )
        return (entry.uid)
示例#5
0
 def get_previous_record(self, in_uid):
     current_rec = self.get_by_id(in_uid)
     query = CabWiki.select().where(CabWiki.time_update > current_rec.time_update).order_by(CabWiki.time_update)
     if query.count() == 0:
         return None
     else:
         return query.get()
示例#6
0
文件: mwiki.py 项目: daimon99/TorCMS
    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

        if 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])

        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,
            src_type=post_data["src_type"][0],
        )
        return entry.uid
示例#7
0
文件: mwiki.py 项目: Geoion/TorCMS
 def query_cat_by_pager(self, cat_str, cureent):
     tt = (
         CabWiki.select()
         .where(CabWiki.id_cats.contains(str(cat_str)))
         .order_by(CabWiki.time_update.desc())
         .paginate(cureent, config.page_num)
     )
     return tt
示例#8
0
文件: mwiki.py 项目: Geoion/TorCMS
 def get_next_record(self, in_uid):
     current_rec = self.get_by_id(in_uid)
     query = (
         CabWiki.select().where(CabWiki.time_update < current_rec.time_update).order_by(CabWiki.time_update.desc())
     )
     if query.count() == 0:
         return None
     else:
         return query.get()
示例#9
0
 def get_previous_record(self, in_uid):
     current_rec = self.get_by_id(in_uid)
     query = CabWiki.select().where(
         CabWiki.time_update > current_rec.time_update).order_by(
             CabWiki.time_update)
     if query.count() == 0:
         return None
     else:
         return query.get()
示例#10
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()
示例#11
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()
示例#12
0
文件: mwiki.py 项目: daimon99/TorCMS
    def update(self, uid, post_data):

        print(post_data["src_type"][0])
        if 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])

        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(),
            src_type=post_data["src_type"][0],
        ).where(CabWiki.uid == uid)
        entry.execute()
示例#13
0
文件: mwiki.py 项目: Ryan007/TorCMS
    def update(self, uid, post_data):


        print(post_data['src_type'][0])
        if 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])

        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=time.time(),
            src_type=post_data['src_type'][0]
        ).where(CabWiki.uid == uid)
        entry.execute()
示例#14
0
    def update(self, uid, post_data):

        print(post_data['src_type'][0])
        if 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])

        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=time.time(),
            # id_spec=id_spec,
            # logo=post_data['logo'][0],
            src_type=post_data['src_type'][0]).where(CabWiki.uid == uid)
        entry.execute()
示例#15
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)
示例#16
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)
示例#17
0
 def get_by_title(self, in_title):
     try:
         return CabWiki.get(CabWiki.title == in_title)
     except:
         return None
示例#18
0
 def get_num_by_cat(self, cat_str):
     return CabWiki.select().where(
         CabWiki.id_cats.contains(',{0},'.format(cat_str))).count()
示例#19
0
 def query_most(self, num=8):
     return CabWiki.select().order_by(CabWiki.view_count.desc()).limit(num)
示例#20
0
 def get_by_id(self, in_uid):
     tt = CabWiki.select().where(CabWiki.uid == in_uid).count()
     if tt == 0:
         return None
     else:
         return CabWiki.get(CabWiki.uid == in_uid)
示例#21
0
 def get_num_by_cat(self, cat_str):
     return CabWiki.select().where(CabWiki.id_cats.contains(',{0},'.format(cat_str))).count()
示例#22
0
文件: mwiki.py 项目: daimon99/TorCMS
 def get_by_title(self, in_title):
     try:
         return CabWiki.get(CabWiki.title == in_title)
     except:
         return None
示例#23
0
 def query_dated(self, num = 10):
     return CabWiki.select().order_by(CabWiki.time_update.desc()).limit(num)
示例#24
0
 def update_view_count(self, citiao):
     entry = CabWiki.update(view_count=CabWiki.view_count +
                            1).where(CabWiki.title == citiao)
     entry.execute()
示例#25
0
 def query_recent_most(self, num=8, recent=30):
     time_that = int(time.time()) - 30 * 24 * 3600
     return CabWiki.select().where(
         CabWiki.time_update > time_that).order_by(
             CabWiki.view_count.desc()).limit(num)
示例#26
0
 def query_random(self, num=6):
     if config.dbtype == 1 or config.dbtype == 3:
         return CabWiki.select().order_by(peewee.fn.Random()).limit(num)
     elif config.dbtype == 2:
         return CabWiki.select().order_by(peewee.fn.Rand()).limit(num)
示例#27
0
文件: mwiki.py 项目: daimon99/TorCMS
 def update_view_count(self, citiao):
     entry = CabWiki.update(view_count=CabWiki.view_count + 1).where(CabWiki.title == citiao)
     entry.execute()
示例#28
0
 def query_recent(self, num=8):
     return CabWiki.select().order_by(CabWiki.time_update.desc()).limit(num)
示例#29
0
 def update_view_count_by_uid(self, uid):
     entry = CabWiki.update(view_count=CabWiki.view_count +
                            1).where(CabWiki.uid == uid)
     entry.execute()
示例#30
0
 def query_recent_most(self, num=8, recent=30):
     time_that = int(time.time()) - 30 * 24 * 3600
     return CabWiki.select().where(CabWiki.time_update > time_that).order_by(CabWiki.view_count.desc()).limit(num)
示例#31
0
文件: mwiki.py 项目: daimon99/TorCMS
 def __init__(self):
     try:
         CabWiki.create_table()
     except:
         pass
示例#32
0
 def __init__(self):
     try:
         CabWiki.create_table()
     except:
         pass
示例#33
0
 def query_cat_by_pager(self, cat_str, cureent):
     tt = CabWiki.select().where(CabWiki.id_cats.contains(
         str(cat_str))).order_by(CabWiki.time_update.desc()).paginate(
             cureent, config.page_num)
     return tt
示例#34
0
文件: mwiki.py 项目: daimon99/TorCMS
 def get_by_keyword(self, par2):
     return CabWiki.select().where(CabWiki.title.contains(par2)).order_by(CabWiki.time_update.desc()).limit(20)
示例#35
0
 def query_old(self):
     return CabWiki.select().order_by('time_update').limit(10)
示例#36
0
 def query_recent(self, num=8):
     return CabWiki.select().order_by(CabWiki.time_update.desc()).limit(num)
示例#37
0
 def query_old(self):
     return CabWiki.select().order_by('time_update').limit(10)
示例#38
0
文件: mwiki.py 项目: daimon99/TorCMS
 def get_by_id(self, in_uid):
     tt = CabWiki.select().where(CabWiki.uid == in_uid).count()
     if tt == 0:
         return None
     else:
         return CabWiki.get(CabWiki.uid == in_uid)
示例#39
0
 def query_random(self, num=6):
     if config.dbtype == 1 or config.dbtype == 3:
         return CabWiki.select().order_by(peewee.fn.Random()).limit(num)
     elif config.dbtype == 2:
         return CabWiki.select().order_by(peewee.fn.Rand()).limit(num)
示例#40
0
文件: mwiki.py 项目: daimon99/TorCMS
 def query_most(self, num=8):
     return CabWiki.select().order_by(CabWiki.view_count.desc()).limit(num)
示例#41
0
 def query_dated(self, num=8):
     return CabWiki.select().order_by(CabWiki.time_update).limit(num)
示例#42
0
文件: mwiki.py 项目: daimon99/TorCMS
 def update_view_count_by_uid(self, uid):
     entry = CabWiki.update(view_count=CabWiki.view_count + 1).where(CabWiki.uid == uid)
     entry.execute()
示例#43
0
 def query_by_spec(self, spec_id):
     tt = CabWiki.select().where(CabWiki.id_spec == spec_id).order_by(
         CabWiki.time_update.desc())
     return tt
示例#44
0
文件: mwiki.py 项目: daimon99/TorCMS
 def query_by_spec(self, spec_id):
     tt = CabWiki.select().where(CabWiki.id_spec == spec_id).order_by(CabWiki.time_update.desc())
     return tt
示例#45
0
 def get_by_keyword(self, par2):
     return CabWiki.select().where(CabWiki.title.contains(par2)).order_by(
         CabWiki.time_update.desc()).limit(20)