Пример #1
0
def configure(cfg):
    board = boards.get_board(cfg.env.BOARD)
    if isinstance(board, boards.px4):
        # toolchain is currently broken for gtest
        cfg.msg(
            'Gtest',
            'PX4 boards currently don\'t support compiling gtest',
            color='YELLOW',
        )
        return

    cfg.env.HAS_GTEST = False

    if cfg.env.STATIC_LINKING:
        # gtest uses a function (getaddrinfo) that is supposed to be linked
        # dynamically
        cfg.msg(
            'Gtest',
            'statically linked tests not supported',
            color='YELLOW',
        )
        return

    cfg.env.append_value('GIT_SUBMODULES', 'gtest')
    cfg.env.HAS_GTEST = True
Пример #2
0
def invite(id):
    board_users = boards.get_secret_board_users(id)
    board = boards.get_board(id)
    userlist = users.get_users()
    if users.user_role() != 2:
        return redirect(url_for('error'))
    if request.method == "GET":
        return render_template("invite.html",
                               id=id,
                               boardname=board[0],
                               board_users=board_users,
                               userlist=userlist)
    if request.method == "POST":
        user_id = request.form["users"]
        if session["csrf_token"] != request.form["csrf_token"]:
            abort(403)
        if int(user_id) == 0:
            return render_template("invite.html",
                                   id=id,
                                   boardname=board[0],
                                   board_users=board_users,
                                   userlist=userlist,
                                   errormessage="Valitse käyttäjä!")
        # Tarkastetaan, onko käyttäjä jo alueella
        user_invited = False
        for row in board_users:
            for elem in row:
                if int(user_id) == elem:
                    user_invited = True
        if request.form["submit"] == 'remove':
            if not user_invited:
                return render_template(
                    "invite.html",
                    id=id,
                    boardname=board[0],
                    board_users=board_users,
                    userlist=userlist,
                    errormessage="Käyttäjä ei ole alueella!")
            if boards.remove_user(user_id, id):
                board_users = boards.get_secret_board_users(id)
                return render_template("invite.html",
                                       id=id,
                                       boardname=board[0],
                                       board_users=board_users,
                                       userlist=userlist)
        elif request.form["submit"] == 'add':
            if user_invited:
                return render_template("invite.html",
                                       id=id,
                                       boardname=board[0],
                                       board_users=board_users,
                                       userlist=userlist,
                                       errormessage="Käyttäjä on jo lisätty!")
            if boards.invite_user(user_id, id):
                board_users = boards.get_secret_board_users(id)
                return render_template("invite.html",
                                       id=id,
                                       boardname=board[0],
                                       board_users=board_users,
                                       userlist=userlist)
Пример #3
0
def configure(cfg):
    board = boards.get_board(cfg.env.BOARD)
    if isinstance(board, boards.px4):
        # toolchain is currently broken for gtest
        cfg.msg(
            'Gtest',
            'PX4 boards currently don\'t support compiling gtest',
            color='YELLOW',
        )
        return

    cfg.env.HAS_GTEST = False

    if cfg.env.STATIC_LINKING:
        # gtest uses a function (getaddrinfo) that is supposed to be linked
        # dynamically
        cfg.msg(
            'Gtest',
            'statically linked tests not supported',
            color='YELLOW',
        )
        return

    cfg.env.append_value('GIT_SUBMODULES', 'gtest')
    cfg.env.HAS_GTEST = True
Пример #4
0
def edit_comment(id):
    comment = comments.get_comment(id)
    if comment == None or comment[3] == 0:
        return redirect(url_for('error'))
    thread_id = comment[2]
    thread = threads.get_thread(thread_id)
    board_id = thread[2]
    board = boards.get_board(board_id)
    if not users.access_rights(comment[0]):
        return redirect(url_for('error'))
    if request.method == "GET":
        return render_template("edit-comment.html",
                               id=id,
                               comment=comment[1],
                               board_id=board_id,
                               boardname=board[0],
                               thread_id=thread_id,
                               thread_title=thread[0])
    if request.method == "POST":
        content = request.form["content"]
        if session["csrf_token"] != request.form["csrf_token"]:
            abort(403)
        if len(content) < 2:
            return render_template(
                "edit-comment.html",
                id=id,
                comment=comment[1],
                board_id=board_id,
                boardname=board[0],
                thread_id=thread_id,
                thread_title=thread[0],
                errormessage="Viestin täytyy olla vähintään 2 merkkiä pitkä.")
        if len(content) > 1000:
            return render_template("edit-comment.html",
                                   id=id,
                                   comment=comment[1],
                                   board_id=board_id,
                                   boardname=board[0],
                                   thread_id=thread_id,
                                   thread_title=thread[0],
                                   errormessage="Viesti on liian pitkä!")
        if comments.edit(content, id):
            return redirect(url_for('thread', id=thread_id))
        else:
            return render_template(
                "edit-comment.html",
                id=id,
                comment=comment[1],
                board_id=board_id,
                boardname=board[0],
                thread_id=thread_id,
                thread_title=thread[0],
                errormessage="Viestin muokkaus ei onnistunut")
Пример #5
0
def thread(id):
    thread = threads.get_thread(id)
    board = boards.get_board(thread[2])
    comments = threads.get_comments(id)
    # Tarkastetaan, että käyttäjällä on pääsy salaisille keskustelualueille
    if board[1] == 1 and boards.secret_board_access(thread[2]) == False:
        return redirect(url_for('error'))
    return render_template("thread.html",
                           id=id,
                           title=thread[0],
                           boardname=board[0],
                           board_id=thread[2],
                           comments=comments)
Пример #6
0
def board(id):
    board = boards.get_board(id)
    secretboardusers = boards.get_secret_board_users(id)
    threadlist = boards.get_threads(id)
    # Tarkastetaan, että käyttäjällä on pääsy salaisille keskustelualueille
    if board[1] == 1 and boards.secret_board_access(id) == False:
        return redirect(url_for('error'))
    return render_template("board.html",
                           id=id,
                           boardname=board[0],
                           threads=threadlist,
                           secret=board[1],
                           secretboardusers=secretboardusers)
Пример #7
0
def create_thread(id):
    boardname = boards.get_board(id)[0]
    if not users.access_rights(users.user_id()):
        return redirect(url_for('error'))
    if request.method == "GET":
        return render_template("create-thread.html",
                               id=id,
                               boardname=boardname)
    if request.method == "POST":
        title = request.form["title"]
        content = request.form["content"]
        if session["csrf_token"] != request.form["csrf_token"]:
            abort(403)
        if len(title) < 2:
            return render_template(
                "create-thread.html",
                id=id,
                boardname=boardname,
                errormessage="Otsikon täytyy olla vähintään 2 merkkiä pitkä.")
        if len(title) > 50:
            return render_template("create-thread.html",
                                   id=id,
                                   boardname=boardname,
                                   errormessage="Liian pitkä otsikko.")
        if len(content) < 2:
            return render_template(
                "create-thread.html",
                id=id,
                boardname=boardname,
                errormessage="Viestin täytyy olla vähintään 2 merkkiä pitkä.")
        if len(content) > 1000:
            return render_template("create-thread.html",
                                   id=id,
                                   boardname=boardname,
                                   errormessage="Viesti on liian pitkä")
        thread_id = boards.create_thread(title, content, id)
        if thread_id:
            return redirect(url_for('thread', id=thread_id))
        else:
            return render_template(
                "create-thread.html",
                id=id,
                boardname=boardname,
                errormessage="Keskustelun luonti ei onnistunut")
Пример #8
0
    def __init__(self):

        # Get random board
        self.board = boards.get_board()