Beispiel #1
0
    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)
Beispiel #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
Beispiel #3
0
 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())
Beispiel #4
0
    def count_of_certain():
        '''
        Get the count of certain kind.
        '''

        recs = TabReply.select()

        return recs.count()
Beispiel #5
0
 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())
Beispiel #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
Beispiel #7
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 Exception as err:
         print(repr(err))
         return False
Beispiel #8
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()

            return True
        except:

            return False
    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
Beispiel #10
0
 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
Beispiel #11
0
 def get_by_uid(uid):
     recs = TabReply.select().where(TabReply.uid == uid)
     if recs.count():
         return recs.get()
     return None
Beispiel #12
0
 def query_pager(current_page_num=1):
     '''
     Query pager
     '''
     return TabReply.select().paginate(current_page_num,
                                       CMS_CFG['list_num'])
Beispiel #13
0
 def total_number():
     '''
     Return the number.
     '''
     # adding ``None`` to hide ``No value for argument 'database' in method call``
     return TabReply.select().count(None)
Beispiel #14
0
 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)
Beispiel #15
0
 def delete(del_id):
     return TabReply.delete().where(TabReply.post_id == del_id)
Beispiel #16
0
 def query_all():
     return TabReply.select().order_by(TabReply.timestamp.desc())
Beispiel #17
0
 def total_number():
     '''
     Return the number.
     '''
     return TabReply.select().count()
Beispiel #18
0
 def update_vote(reply_id, count):
     entry = TabReply.update(vote=count).where(TabReply.uid == reply_id)
     entry.execute()
Beispiel #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()