def edit(id): album = get_model().read(id) if request.method == 'POST': data = request.form.to_dict(flat=True) album = get_model().update(data, id) return redirect(url_for('.view', id=album['id'])) return render_template("form.html", action="Edit", album=album)
def list(): token = request.args.get('page_token', None) albums, next_page_token = get_model().list(cursor=token) return render_template("list.html", albums=albums, next_page_token=next_page_token)
def add(): if request.method == 'POST': data = request.form.to_dict(flat=True) album = get_model().create(data) return redirect(url_for('.view', id=album['id'])) return render_template("form.html", action="Add", album={})
def delete(id): get_model().delete(id) return redirect(url_for('.list'))
def view(id): album = get_model().read(id) return render_template("view.html", album=album)