예제 #1
0
 def get_by_wiki(self, citiao):
     tt = CabReply.select().where(CabReply.title == citiao).count()
     if tt == 0:
         return None
     else:
         self.update_view_count(citiao)
         return CabReply.get(CabReply.title == citiao)
예제 #2
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 CabReply.select().join(CabPost2Catalog).where(
             CabPost2Catalog.catalog == cat_id).order_by(
                 peewee.fn.Random()).limit(num)
     elif config.dbtype == 2:
         return CabReply.select().join(CabPost2Catalog).where(
             CabPost2Catalog.catalog == cat_id).order_by(
                 peewee.fn.Rand()).limit(num)
예제 #3
0
파일: mreply.py 프로젝트: hitrustnet/TorCMS
    def update_vote(self, reply_id, count):

        entry = CabReply.update(
            vote=count
        ).where(CabReply.uid == reply_id)

        entry.execute()
예제 #4
0
파일: mreply.py 프로젝트: hitrustnet/TorCMS
    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
예제 #5
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
예제 #6
0
 def get_previous_record(self, in_uid):
     current_rec = self.get_by_id(in_uid)
     query = CabReply.select().where(
         CabReply.time_update > current_rec.time_update).order_by(
             CabReply.time_update)
     if query.count() == 0:
         return None
     else:
         return query.get()
예제 #7
0
    def delete(self, del_id):

        try:
            del_count = CabReply.delete().where(CabReply.uid == del_id)
            del_count.execute()

            del_count2 = CabVoter2Reply.delete().where(CabVoter2Reply.reply_id == del_id)
            del_count2.execute()
            return True
        except:
            return False
예제 #8
0
    def delete(self, del_id):

        try:
            del_count = CabReply.delete().where(CabReply.uid == del_id)
            del_count.execute()

            del_count2 = CabVoter2Reply.delete().where(
                CabVoter2Reply.reply_id == del_id)
            del_count2.execute()
            return True
        except:
            return False
예제 #9
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 == True:
            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=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(CabReply.uid == uid)
        else:
            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=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(CabReply.uid == uid)
        entry.execute()
예제 #10
0
파일: mreply.py 프로젝트: hitrustnet/TorCMS
    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 = 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(),
                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(CabReply.uid == uid)
        else:
            entry = CabReply.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(CabReply.uid == uid)
        entry.execute()
예제 #11
0
 def update_view_count(self, citiao):
     entry = CabReply.update(view_count=CabReply.view_count +
                             1).where(CabReply.title == citiao)
     entry.execute()
예제 #12
0
 def query_cat_by_pager(self, cat_str, cureent):
     tt = CabReply.select().where(CabReply.id_cats.contains(
         str(cat_str))).order_by(CabReply.time_update.desc()).paginate(
             cureent, config.page_num)
     return tt
예제 #13
0
 def query_recent_most(self, num=8, recent=30):
     time_that = int(time.time()) - recent * 24 * 3600
     return CabReply.select().where(
         CabReply.time_update > time_that).order_by(
             CabReply.view_count.desc()).limit(num)
예제 #14
0
 def query_most(self, num=8):
     return CabReply.select().order_by(
         CabReply.view_count.desc()).limit(num)
예제 #15
0
# -*- coding:utf-8 -*-
"""
Author: Bu Kun
E-mail: bukun#osgeo.cn
CopyRight: http://www.yunsuan.org
Bu Kun's Homepage: http://bukun.net
"""

from torlite.model.core_tab import CabReply
from torlite.model.core_tab import CabPost2Reply
from torlite.model.core_tab import CabPost

try:
    CabReply.create_table()
except:
    pass

try:
    CabPost2Reply.create_table()
except:
    pass

uu = CabPost()

members = [attr for attr in dir(CabPost()) if not callable(getattr(CabPost(), attr)) and not attr.startswith("_")]

print(members)

print("=" * 20)
for kew in vars(CabPost):
    print(kew)
예제 #16
0
파일: mreply.py 프로젝트: hitrustnet/TorCMS
 def __init__(self):
     try:
         CabReply.create_table()
     except:
         pass
예제 #17
0
 def get_by_keyword(self, par2):
     return CabReply.select().where(CabReply.title.contains(par2)).order_by(
         CabReply.time_update.desc()).limit(20)
예제 #18
0
 def query_by_spec(self, spec_id):
     tt = CabReply.select().where(CabReply.id_spec == spec_id).order_by(
         CabReply.time_update.desc())
     return tt
예제 #19
0
 def get_num_by_cat(self, cat_str):
     return CabReply.select().where(
         CabReply.id_cats.contains(',{0},'.format(cat_str))).count()
예제 #20
0
 def get_reply_by_uid(self, reply_id):
     rec = CabReply.get(CabReply.uid == reply_id)
     return rec
예제 #21
0
 def get_by_id(self, in_uid):
     recs = CabReply.select().where(CabReply.post_id == in_uid).order_by(
         CabReply.timestamp.desc())
     return recs
예제 #22
0
 def update_view_count_by_uid(self, uid):
     entry = CabReply.update(view_count=CabReply.view_count +
                             1).where(CabReply.uid == uid)
     entry.execute()
예제 #23
0
 def update_keywords(self, uid, inkeywords):
     entry = CabReply.update(keywords=inkeywords).where(CabReply.uid == uid)
     entry.execute()
예제 #24
0
 def query_random(self, num=6):
     if config.dbtype == 1 or config.dbtype == 3:
         return CabReply.select().order_by(peewee.fn.Random()).limit(num)
     elif config.dbtype == 2:
         return CabReply.select().order_by(peewee.fn.Rand()).limit(num)
예제 #25
0
 def query_all(self):
     return CabReply.select()
예제 #26
0
파일: mreply.py 프로젝트: hitrustnet/TorCMS
 def get_reply_by_uid(self, reply_id):
     rec = CabReply.get(CabReply.uid == reply_id)
     return rec
예제 #27
0
 def __init__(self):
     try:
         CabReply.create_table()
     except:
         pass
예제 #28
0
 def query_keywords_empty(self):
     return CabReply.select().where(CabReply.keywords == '')
예제 #29
0
    def update_vote(self, reply_id, count):

        entry = CabReply.update(vote=count).where(CabReply.uid == reply_id)

        entry.execute()
예제 #30
0
 def query_recent(self, num=8):
     return CabReply.select().order_by(
         CabReply.time_update.desc()).limit(num)
예제 #31
0
 def query_old(self):
     return CabReply.select().order_by('time_update').limit(10)
예제 #32
0
 def query_dated(self, num=8):
     return CabReply.select().order_by(CabReply.time_update).limit(num)
예제 #33
0
# -*- coding:utf-8 -*-
'''
Author: Bu Kun
E-mail: bukun#osgeo.cn
CopyRight: http://www.yunsuan.org
Bu Kun's Homepage: http://bukun.net
'''

from torlite.model.core_tab import CabReply
from torlite.model.core_tab import CabPost2Reply
from torlite.model.core_tab import CabPost

try:
    CabReply.create_table()
except:
    pass

try:
    CabPost2Reply.create_table()
except:
    pass

uu = CabPost()

members = [attr for attr in dir(CabPost())
           if not callable(getattr(CabPost(), attr))
           and not attr.startswith("_")]

print(members)

print('=' * 20)
예제 #34
0
 def query_cat_recent(self, cat_id, num=8):
     return CabReply.select().join(CabPost2Catalog).where(
         CabPost2Catalog.catalog == cat_id).order_by(
             CabReply.time_update.desc()).limit(num)