示例#1
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)
 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)
 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()
 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)
示例#5
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()
示例#6
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)
示例#7
0
 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)
示例#8
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)
示例#9
0
 def query_recent(self, num=8):
     return CabPost.select().order_by(CabPost.time_update.desc()).limit(num)
示例#10
0
 def query_all(self):
     return CabPost.select()
示例#11
0
文件: mpost.py 项目: daimon99/TorCMS
 def query_all(self):
     return CabPost.select()
示例#12
0
 def delete_last_post(self):
     #Todo: delete
     query = CabPost.select().order_by(
         CabPost.time_update.desc()).limit(1).get()
     self.delete(query.uid)
示例#13
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)
示例#14
0
文件: mpost.py 项目: daimon99/TorCMS
 def query_old(self):
     return CabPost.select().order_by('time_update').limit(10)
示例#15
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)
示例#16
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)
示例#17
0
文件: mpost.py 项目: daimon99/TorCMS
 def query_recent(self, num=8):
     return CabPost.select().order_by(CabPost.time_update.desc()).limit(num)
示例#18
0
 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)
示例#19
0
 def get_by_keyword(self, par2):
     return CabPost.select().where(CabPost.title.contains(par2)).order_by(
         CabPost.time_update.desc()).limit(20)
示例#20
0
 def delete_last_post(self):
     #Todo: delete
     query = CabPost.select().order_by(  CabPost.time_update.desc()).limit(1).get()
     self.delete(query.uid)
示例#21
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
示例#22
0
 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()
示例#23
0
 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)
示例#24
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()
示例#25
0
 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)
示例#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
 def get_num_by_cat(self, cat_str):
     return CabPost.select().where(
         CabPost.id_cats.contains(',{0},'.format(cat_str))).count()
示例#28
0
 def query_keywords_empty(self):
     return CabPost.select().where(CabPost.keywords == '')
示例#29
0
 def query_keywords_empty(self):
     return CabPost.select().where(CabPost.keywords == '')
示例#30
0
 def query_by_spec(self, spec_id):
     return CabPost.select().where(CabPost.id_spec == spec_id).order_by(CabPost.time_update.desc())
示例#31
0
 def query_dated(self, num=8):
     return CabPost.select().order_by(CabPost.time_update).limit(num)
示例#32
0
 def query_dated(self, num=8):
     return CabPost.select().order_by(CabPost.time_update.asc()).limit(num)
示例#33
0
 def query_most(self, num=8):
     return CabPost.select().order_by(CabPost.view_count.desc()).limit(num)
示例#34
0
 def query_most_pic(self, num):
      return CabPost.select().where( CabPost.logo != "").order_by(CabPost.view_count.desc()).limit(num)
示例#35
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
示例#36
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)
示例#37
0
 def query_by_spec(self, spec_id):
     tt = CabPost.select().where(CabPost.id_spec == spec_id).order_by(
         CabPost.time_update.desc())
     return tt
示例#38
0
 def query_most(self, num=8):
     return CabPost.select().order_by(CabPost.view_count.desc()).limit(num)
示例#39
0
 def query_old(self):
     return CabPost.select().order_by('time_update').limit(10)
示例#40
0
 def query_most_pic(self, num):
     return CabPost.select().where(CabPost.logo != "").order_by(
         CabPost.view_count.desc()).limit(num)