Ejemplo n.º 1
0
    async def create_board(self, ctx):
        """handler to create a new board"""
        sent_data = ctx.sent_data
        ws = ctx.extensions.get('ws')
        jwt = ctx.services.get('jwt')
        user = ctx.user

        snowflake = ctx.services.get('snowflake')
        new_board_uid = await snowflake()
        new_board = Board(uid=new_board_uid,
                          name=sent_data['name'],
                          owner_id=user.uid)
        new_board.save()
        owner_role = Role(uid=await snowflake(), name='Owner', permissions=8)
        everyone_role = Role(uid=await snowflake(),
                             name='everyone',
                             permissions=104324161)
        general_channel = Channel(uid=await snowflake(),
                                  name='general',
                                  type=0,
                                  topic='general discussion',
                                  position=0)
        owner_role.save()
        everyone_role.save()
        general_channel.save()
        everyone_role.parents.connect(owner_role)
        new_board.roles.connect(owner_role)
        new_board.roles.connect(everyone_role)
        new_board.subscribers.connect(user, {'role': owner_role.uid})
        new_board.channel_children.connect(general_channel)
        await ws.event(EventType.BOARD_CREATE,
                       new_board.subscribers,
                       board=new_board)
        return ctx.respond(jsonify(new_board, requester=user))
Ejemplo n.º 2
0
def read(id):
    board = Board()
    board = board.query.get(id)
    board.count = db.session.query(func.max(Board.count)).one()[0]
    if board.count == None:
        board.count = 0
    else:
        board.count += 1

    db.session.add(board)
    db.session.commit()

    return render_template("read.html", board=board)
Ejemplo n.º 3
0
def read(id):
    board = Board()
    board = board.query.get(id)
    board.count = db.session.query(func.max(Board.count), ).one()[0]
    if board.count == None:
        board.count = 0
    else:
        board.count += 1

    db.session.add(board)
    db.session.commit()

    return render_template("read.html", board=board)
Ejemplo n.º 4
0
def w_success():

    board = Board()

    if request.method == "POST":
        title = request.form['title']
        text = request.form['textarea']

        board.title = title
        board.text = text
        board.writer = username()

        board.num = db.session.query(func.max(Board.num), ).one()[0]
        if board.num == None:
            board.num = 1
        else:
            board.num += 1

        db.session.add(board)
        db.session.commit()

    return redirect(url_for("list"))
Ejemplo n.º 5
0
def w_success():

    board = Board()

    if request.method == "POST":
        title = request.form["title"]
        text = request.form["textarea"]

        board.title = title
        board.text = text
        board.writer = username()

        board.num = db.session.query(func.max(Board.num)).one()[0]
        if board.num == None:
            board.num = 1
        else:
            board.num += 1

        db.session.add(board)
        db.session.commit()

    return redirect(url_for("list"))