Esempio n. 1
0
def insert_board():
    if request.method == 'POST':
        print('insert board post opt')
        board = system.Board()
        board.boardname = request.form['boardname']
        board.boardtopics = request.form['boardtopics']
        board.boardmanager = request.form['boardmanager2']
        board.boardintroduce = request.form['boardintroduce']
        status = board.insert_board()
        if status:
            board_list = board.query_board()
            return render_template('board_list.html', result=board_list)
        return 'insert error'
    user = system.User()
    user_list = user.query_all_user()
    len1 = len(user_list)
    for i in user_list:
        print(i)
    # admin_list = []
    # for i in user_list:
    #     if i[3] == 0:
    #         admin_list.append(i)
    # print(admin_list)
    print('insert board get opt')
    return render_template('board_detail.html', user_list=user_list, len1=len1)
Esempio n. 2
0
def query_board2():
    board = system.Board()
    if request.method == 'POST':
        return render_template('board2.html')
    # get操作,先获取数据库中的board
    # query_board_sql = 'select * from board;'
    result = board.query_board()
    return render_template('board2.html', result=result)
Esempio n. 3
0
def single(boardid, usertype, bbsid):
    board = system.Board()
    bbs = system.Bbs()
    print('boardid :', boardid, '\n usertype :', usertype, '\n bbsid :', bbsid)
    boardid_dict = board.query_board()  # 查询所有版块
    bbs.bbsid = bbsid
    bbs_result = bbs.query_by_bbsid()  # 根据bbsid查询单个帖子
    all_bbs = bbs.query_all_bbs()  # 查询所有帖子
    bbsid_reply = {}  # 字典:{ 帖子id: 帖子回复数 }
    for i in all_bbs:
        # print('bbsid :', i[0])
        bbs.bbsid = i[0]
        result = bbs.bbs_sum_reply()  # 查询帖子回复数
        sum = 0
        for j in result:
            sum += j[0]
        bbsid_reply[i[0]] = sum  # 将{ 帖子id: 帖子回复数 } 放入字典
    # print(' bbs_result :\n', bbs_result)
    return render_template('single.html',
                           result=bbs_result,
                           boardid_dict=boardid_dict,
                           bbsid_reply=bbsid_reply)
Esempio n. 4
0
def bbs_list():
    board = system.Board()
    bbs = system.Bbs()
    boardid_dict = board.query_board()  # 查询所有版块
    order_by_click = bbs.clicking_ranking()  # 根据帖子点击率对帖子进行排序
    all_bbs = bbs.query_all_bbs()  # 查询所有帖子
    bbsid_reply = {}  # 字典:{ 帖子id: 帖子回复数 }
    for i in all_bbs:
        # print('bbsid :', i[0])
        bbs.bbsid = i[0]
        result = bbs.bbs_sum_reply()  # 查询帖子回复数
        sum = 0
        for j in result:
            sum += j[0]
        # print('bbsid :', i[0], ' sum_reply :', sum)
        bbsid_reply[i[0]] = sum  # 将{ 帖子id: 帖子回复数 } 放入字典
    # print('bbsid_reply dict :', bbsid_reply)
    # print('order_by_click :', order_by_click,
    #       '\n boardid_dict :', boardid_dict,
    #       '\n bbsid_reply :', bbsid_reply)
    return render_template('articles-list.html',
                           order_by_click=order_by_click,
                           boardid_dict=boardid_dict,
                           bbsid_reply=bbsid_reply)
Esempio n. 5
0
def update_board_detail():
    if request.method == 'POST':
        board = system.Board()
        board.update_board()
        return render_template('board_detail.html')
    return render_template('board_detail.html')
Esempio n. 6
0
def board_list():
    if request.method == 'POST':
        return ''
    board = system.Board()
    board_list = board.query_board()
    return render_template('board_list.html', result=board_list)