Beispiel #1
0
def add_channel():
    form = ChannelForm(request.form)
    if request.method == 'POST' and form.validate():
        channel = Channel(name = form.name.data)
        channel.owner_id = g.user.id
        db.session.add(channel)
        db.session.commit()
        return redirect(url_for('channel_view', id=channel.id))
    return render_template('add_channel.html',
        title = 'Add channel',
        user = g.user,
        form = form)
Beispiel #2
0
def search():
    form = ChannelForm(request.form)
    if request.method == "POST"  and form.validate():
        channels = Channel.query.filter(Channel.name.like(
            '%' + form.name.data + '%' ))
    else:
        channels = Channel.query.all()
    return render_template('search.html',
        channels=channels,
        form = form,
    	title = 'Search channels',
        user = g.user)