def board_lists(board_id): """ Returns all the lists belongs to the board specified by board id. """ if not Board.has_access_to(g.user.netid, board_id): return error(Error.NO_ACCESS_TO_BOARD) lists = List.get_lists_by_board_id(board_id) return ok({"lists": map(lambda x: x.to_dict(), lists)})
def add_list(): """ Adds a list specified by list name and board id. Returns the created list id. """ list_name = request.form.get("name") board_id = request.form.get("board_id") if not list_name: return error(Error.EMPTY_LIST_NAME, 400) elif not board_id: return error(Error.EMPTY_BOARD_ID, 400) if not Board.has_access_to(g.user.netid, board_id): return error(Error.NO_ACCESS_TO_BOARD, 400) list_ = List.add_list(board_id, list_name) return ok({"created": True, "list": list_.to_dict()})
def board_list(board_id): """ GET: get all lists of the specified board POST: add a list to the specified board Return JSON. """ if request.method == 'GET': lists = List.get_lists_by_board_id(board_id) return ok({"lists": map(lambda x: x.to_dict(), lists)}) elif request.method == 'POST': name = request.form.get("name") if not name: return error(Error.EMPTY_LIST_NAME, 400) if not Board.has_access_to(g.user.netid, board_id): return error(Error.NO_ACCESS_TO_BOARD, 400) list_ = List.add_list(board_id, name) return ok({"created": True, "list": list_.to_dict()})
def board_page(board_id): if not Board.has_access_to(g.user.netid, board_id): return render_template("no_access.html") lists = List.get_lists_by_board_id(board_id) return render_template("board_page.html", lists=lists)