コード例 #1
0
ファイル: mpost.py プロジェクト: vaveee/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
コード例 #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
 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)
コード例 #4
0
    def insert_data(self, id_post, post_data):

        uu = self.get_by_id(id_post)
        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 '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])

        entry = CabPost.create(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            uid=id_post,
            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,
            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
        )
        return (entry.uid)
コード例 #5
0
ファイル: mpost.py プロジェクト: vaveee/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
コード例 #6
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()
コード例 #7
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 = CabPost.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(CabPost.uid == uid)
        else:
            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]),
                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(CabPost.uid == uid)
        entry.execute()
コード例 #8
0
ファイル: mpost.py プロジェクト: vaveee/TorCMS
    def insert_data(self, id_post, post_data):

        uu = self.get_by_id(id_post)
        if uu is None:
            pass
        else:
            return (False)

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

        entry = CabPost.create(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            uid=id_post,
            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,
            logo=post_data['logo'][0],
            keywords=post_data['keywords'][0],
        )
        return (entry.uid)
コード例 #9
0
 def update_view_count_by_uid(self, uid):
     entry = CabPost.update(view_count=CabPost.view_count + 1).where(CabPost.uid == uid)
     entry.execute()
コード例 #10
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
コード例 #11
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)
コード例 #12
0
 def query_dated(self, num=8):
     return CabPost.select().order_by(CabPost.time_update.asc()).limit(num)
コード例 #13
0
 def query_keywords_empty(self):
     return CabPost.select().where(CabPost.keywords == '')
コード例 #14
0
ファイル: mpost.py プロジェクト: tianzhaodong/TorCMS
 def query_by_spec(self, spec_id):
     return CabPost.select().where(CabPost.id_spec == spec_id).order_by(
         CabPost.time_update.desc())
コード例 #15
0
 def query_dated(self, num=8):
     return CabPost.select().order_by(CabPost.time_update.asc()).limit(num)
コード例 #16
0
 def delete_last_post(self):
     # Todo: delete
     query = CabPost.select().order_by(
         CabPost.time_update.desc()).limit(1).get()
     self.delete(query.uid)
コード例 #17
0
 def __init__(self):
     self.tab = CabPost
     try:
         CabPost.create_table()
     except:
         pass
コード例 #18
0
 def update_keywords(self, uid, inkeywords):
     entry = CabPost.update(keywords=inkeywords).where(CabPost.uid == uid)
     entry.execute()
コード例 #19
0
 def update_view_count(self, citiao):
     entry = CabPost.update(view_count=CabPost.view_count +
                            1).where(CabPost.title == citiao)
     entry.execute()
コード例 #20
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
コード例 #21
0
 def query_most(self, num=8):
     return CabPost.select().order_by(CabPost.view_count.desc()).limit(num)
コード例 #22
0
 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
 def get_num_by_cat(self, cat_str):
     return CabPost.select().where(
         CabPost.id_cats.contains(',{0},'.format(cat_str))).count()
コード例 #24
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)
コード例 #25
0
 def query_keywords_empty(self):
     return CabPost.select().where(CabPost.keywords == '')
コード例 #26
0
 def get_num_by_cat(self, cat_str):
     return CabPost.select().where(CabPost.id_cats.contains(',{0},'.format(cat_str))).count()
コード例 #27
0
ファイル: mpost.py プロジェクト: daimon99/TorCMS
 def get_by_id(self, in_uid):
     recs = CabPost.select().where(CabPost.uid == in_uid)
     if recs.count() == 0:
         return None
     else:
         return recs.get()
コード例 #28
0
 def query_by_spec(self, spec_id):
     return CabPost.select().where(CabPost.id_spec == spec_id).order_by(CabPost.time_update.desc())
コード例 #29
0
ファイル: mpost.py プロジェクト: daimon99/TorCMS
 def query_all(self):
     return CabPost.select()
コード例 #30
0
 def query_most_pic(self, num):
      return CabPost.select().where( CabPost.logo != "").order_by(CabPost.view_count.desc()).limit(num)
コード例 #31
0
ファイル: mpost.py プロジェクト: daimon99/TorCMS
 def query_recent(self, num=8):
     return CabPost.select().order_by(CabPost.time_update.desc()).limit(num)
コード例 #32
0
 def query_most(self, num=8):
     return CabPost.select().order_by(CabPost.view_count.desc()).limit(num)
コード例 #33
0
ファイル: mpost.py プロジェクト: daimon99/TorCMS
 def query_recent_most(self, num=8, recent=30):
     time_that = int(time.time()) - recent * 24 * 3600
     return CabPost.select().where(CabPost.time_update > time_that).order_by(CabPost.view_count.desc()).limit(num)
コード例 #34
0
 def update_view_count(self, citiao):
     entry = CabPost.update(view_count=CabPost.view_count + 1).where(CabPost.title == citiao)
     entry.execute()
コード例 #35
0
ファイル: mpost.py プロジェクト: daimon99/TorCMS
 def get_by_keyword(self, par2):
     return CabPost.select().where(CabPost.title.contains(par2)).order_by(CabPost.time_update.desc()).limit(20)
コード例 #36
0
 def update_keywords(self, uid, inkeywords):
     entry = CabPost.update(keywords=inkeywords).where(CabPost.uid == uid)
     entry.execute()
コード例 #37
0
ファイル: mpost.py プロジェクト: tianzhaodong/TorCMS
 def update_view_count_by_uid(self, uid):
     entry = CabPost.update(view_count=CabPost.view_count +
                            1).where(CabPost.uid == uid)
     entry.execute()
コード例 #38
0
ファイル: mpost.py プロジェクト: daimon99/TorCMS
 def query_old(self):
     return CabPost.select().order_by('time_update').limit(10)
コード例 #39
0
ファイル: mpost.py プロジェクト: daimon99/TorCMS
 def query_random(self, num=6):
     if config.dbtype == 1 or config.dbtype == 3:
         return CabPost.select().order_by(peewee.fn.Random()).limit(num)
     elif config.dbtype == 2:
         return CabPost.select().order_by(peewee.fn.Rand()).limit(num)
コード例 #40
0
 def __init__(self):
     self.tab = CabPost
     try:
         CabPost.create_table()
     except:
         pass
コード例 #41
0
ファイル: mpost2catalog.py プロジェクト: Geoion/TorCMS
 def query_pager_by_slug(self, slug, current_page_num=1):
     return CabPost.select().join(CabPost2Catalog).join(CabCatalog).where(CabCatalog.slug == slug).order_by(
         CabPost.time_update.desc()).paginate(current_page_num, config.page_num)
コード例 #42
0
ファイル: mpost.py プロジェクト: daimon99/TorCMS
 def get_by_uid(self, sig):
     try:
         return CabPost.get(uid=sig)
     except:
         return False
コード例 #43
0
 def query_most_pic(self, num):
     return CabPost.select().where(CabPost.logo != "").order_by(
         CabPost.view_count.desc()).limit(num)