コード例 #1
0
ファイル: post_model.py プロジェクト: mantiswang/TorCMS
    def delete(uid):
        '''
        Delete by uid
        :param uid:
        :return:
        '''

        q_u1 = TabPostHist.delete().where(TabPostHist.post_id == uid)
        q_u1.execute()
        q_u2 = TabRel.delete().where(TabRel.post_f_id == uid
                                     or TabRel.post_t_id == uid)
        q_u2.execute()
        q_u3 = TabCollect.delete().where(TabCollect.post_id == uid)
        q_u3.execute()
        q_u4 = TabPost2Tag.delete().where(TabPost2Tag.post_id == uid)
        q_u4.execute()
        q_u5 = TabUsage.delete().where(TabUsage.post_id == uid)
        q_u5.execute()

        reply_arr = []
        for reply in TabUser2Reply.select().where(
                TabUser2Reply.reply_id == uid):
            reply_arr.append(reply.reply_id.uid)

        q_u6 = TabUser2Reply.delete().where(TabUser2Reply.reply_id == uid)
        q_u6.execute()

        for replyid in reply_arr:
            TabReply.delete().where(TabReply.uid == replyid).execute()

        q_u7 = TabEvaluation.delete().where(TabEvaluation.post_id == uid)
        q_u7.execute()
        q_u8 = TabRating.delete().where(TabRating.post_id == uid)
        q_u8.execute()
        return MHelper.delete(TabPost, uid)
コード例 #2
0
 def create_reply(post_data):
     '''
     Create the reply.
     '''
     uid = tools.get_uuid()
     TabReply.create(uid=uid,
                     post_id=post_data['post_id'],
                     user_name=post_data['user_name'],
                     user_id=post_data['user_id'],
                     timestamp=tools.timestamp(),
                     date=datetime.datetime.now(),
                     cnt_md=tornado.escape.xhtml_escape(
                         post_data['cnt_reply']),
                     cnt_html=tools.markdown2html(post_data['cnt_reply']),
                     vote=0)
     return uid
コード例 #3
0
ファイル: reply_model.py プロジェクト: Silentsoul04/TorCMS
 def query_by_post(postid):
     '''
     Get reply list of certain post.
     '''
     return TabReply.select().where((TabReply.post_id == postid)
                                    & (TabReply.category != '1')).order_by(
                                        TabReply.timestamp.desc())
コード例 #4
0
    def count_of_certain():
        '''
        Get the count of certain kind.
        '''

        recs = TabReply.select()

        return recs.count()
コード例 #5
0
ファイル: reply_model.py プロジェクト: zombiz/TorCMS
 def query_by_post(postid):
     '''
     Get reply list of certain post.
     :param postid:
     :return:
     '''
     return TabReply.select().where(TabReply.post_id == postid).order_by(
         TabReply.timestamp.desc())
コード例 #6
0
 def delete_by_uid(del_id):
     delcom = TabReplyid.delete().where(TabReplyid.reply1 == del_id)
     delcom.execute()
     entry = TabReply.delete().where(TabReply.uid == del_id)
     try:
         entry.execute()
         return True
     except:
         return False
コード例 #7
0
ファイル: reply_model.py プロジェクト: Silentsoul04/TorCMS
 def delete_by_uid(del_id):
     delcom = TabReplyid.delete().where(TabReplyid.reply1 == del_id)
     delcom.execute()
     entry = TabReply.delete().where(TabReply.uid == del_id)
     try:
         entry.execute()
         return True
     except Exception as err:
         print(repr(err))
         return False
コード例 #8
0
ファイル: reply2user_model.py プロジェクト: yangmaoer/TorCMS
    def delete(uid):
        try:
            del_count2 = TabUser2Reply.delete().where(TabUser2Reply.reply_id == uid)
            del_count2.execute()

            del_count = TabReply.delete().where(TabReply.uid == uid)
            del_count.execute()

            return True
        except:

            return False
コード例 #9
0
    def delete(uid):
        try:

            del_count2 = TabUser2Reply.delete().where(
                TabUser2Reply.reply_id == uid)
            del_count2.execute()

            del_count = TabReply.delete().where(TabReply.uid == uid)
            del_count.execute()

            rec = TabReplyid.select().where(TabReplyid.reply0 == uid)
            for x in rec:
                del_count3 = TabReply.delete().where(TabReply.uid == x.reply1)
                del_count3.execute()

            del_count4 = TabReplyid.delete().where(TabReplyid.reply0 == uid)
            del_count4.execute()

            return True
        except Exception as err:
            print(repr(err))
            return False
コード例 #10
0
ファイル: reply_model.py プロジェクト: Silentsoul04/TorCMS
 def modify_by_uid(pid, post_data):
     rec = MReply.get_by_uid(pid)
     if rec:
         entry = TabReply.update(
             user_name=post_data['user_name'],
             user_id=post_data['user_id'],
             category=post_data['category'],
             timestamp=tools.timestamp(),
             date=datetime.datetime.now(),
             cnt_md=tornado.escape.xhtml_escape(post_data['cnt_reply']),
             cnt_html=tools.markdown2html(post_data['cnt_reply']),
         ).where(TabReply.uid == pid)
         entry.execute()
         return pid
コード例 #11
0
ファイル: reply_model.py プロジェクト: Silentsoul04/TorCMS
 def get_by_uid(uid):
     recs = TabReply.select().where(TabReply.uid == uid)
     if recs.count():
         return recs.get()
     return None
コード例 #12
0
ファイル: reply_model.py プロジェクト: Silentsoul04/TorCMS
 def query_pager(current_page_num=1):
     '''
     Query pager
     '''
     return TabReply.select().paginate(current_page_num,
                                       CMS_CFG['list_num'])
コード例 #13
0
ファイル: reply_model.py プロジェクト: Silentsoul04/TorCMS
 def total_number():
     '''
     Return the number.
     '''
     # adding ``None`` to hide ``No value for argument 'database' in method call``
     return TabReply.select().count(None)
コード例 #14
0
ファイル: reply_model.py プロジェクト: Silentsoul04/TorCMS
 def count_of_certain():
     '''
     Get the count of certain kind.
     '''
     # adding ``None`` to hide ``No value for argument 'database' in method call``
     return TabReply.select().count(None)
コード例 #15
0
ファイル: reply_model.py プロジェクト: Silentsoul04/TorCMS
 def delete(del_id):
     return TabReply.delete().where(TabReply.post_id == del_id)
コード例 #16
0
ファイル: reply_model.py プロジェクト: Silentsoul04/TorCMS
 def query_all():
     return TabReply.select().order_by(TabReply.timestamp.desc())
コード例 #17
0
 def total_number():
     '''
     Return the number.
     '''
     return TabReply.select().count()
コード例 #18
0
ファイル: reply_model.py プロジェクト: Silentsoul04/TorCMS
 def update_vote(reply_id, count):
     entry = TabReply.update(vote=count).where(TabReply.uid == reply_id)
     entry.execute()
コード例 #19
0
 def count_of_comment(postid):
     recs = TabReply.select().join(
         TabPost,
         on=(TabReply.post_id == TabPost.uid)).where(TabPost.uid == postid)
     return recs.count()