示例#1
0
文件: views.py 项目: t-ruas/notepanel
def board_add():
    board_name = flask.request.form["boardName"]
    board_privacy = flask.request.form["boardPrivacy"]
    board_default_options = flask.request.form["defaultOptions"]
    # addnote checkbox in the create board form is meaningfull only for public board
    default_options = default_options if (board_privacy==BoardPrivacy.PUBLIC) else BoardOptions.ADDNOTE
    board = BoardService().add(creator_id=flask.session['user_id'], board_name=board_name, board_privacy=board_privacy, default_options=board_default_options)
    flask.session['board_id'] = board.id
    return flask.jsonify(board=board.to_dic())
示例#2
0
文件: views.py 项目: t-ruas/notepanel
def boards_delete(id):
    flask.session["board_id"] = id
    bs = BoardService()
    board_user = bs.get_user(id, flask.session["user_id"])
    if board_user is None:
        return "", 404
    if board_user.user_group != UserGroup.OWNER:
        return "", 403
    bs.remove(id)
    return "", 200
示例#3
0
文件: views.py 项目: t-ruas/notepanel
def board_users(id):
    flask.session["board_id"] = id
    bs = BoardService()
    board_user = bs.get_user(id, flask.session["user_id"])
    if board_user is None:
        return "", 404
    else:
        users = bs.get_users(id)
        json_users = [];
        for user in users:
            json_users.append(user.to_dic())
        return flask.jsonify(boardUsers=json_users)
示例#4
0
文件: views.py 项目: t-ruas/notepanel
def board(id):
    flask.session["board_id"] = id
    bs = BoardService()
    board_user = bs.get_user(id, flask.session["user_id"])
    if board_user is None:
        return "", 404
    else:
        board = bs.get(id)
        users = bs.get_users(id)
        json_users = [];
        user_group = UserGroup.VIEWER
        for user in users:
            json_users.append(user.to_dic())
            if user.id == flask.session["user_id"]:
                user_group = user.user_group
        return flask.jsonify(board=board.to_dic(), user_group=user_group, boardUsers=json_users)