def index(): if request.method == 'POST': name = request.form.get('name', '') if not name: flash('Name field is mandatory!', 'error') else: hq = 1 if request.form.get('hq', '') else 0 ignore = 1 if request.form.get('ignore', '') else 0 feed_name = request.form.get('feed_name', '') id = request.form.get('id', '') if id: # update show db_execute('update shows set name=?, feed_name=?, hq=?, ignore=? where id=?', [name, feed_name, hq, ignore, id]) flash('Added show %s' % request.form['name']) else: # new show db_execute('insert into shows (name, feed_name, hq, ignore) values (?, ?, ?, ?)', [name, feed_name, hq, ignore]) flash('Added show %s' % request.form['name']) #model.new_show(params.name, params.feed_name, hq, ignore) shows = get_show_list() return render_template('shows_shows.html', shows=shows)
def delete(showid): db_execute('delete from shows where id=?', [showid]) flash('Deleted show with id %s' % showid) return redirect('/shows/')