Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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={})
Пример #4
0
def delete(id):
    get_model().delete(id)
    return redirect(url_for('.list'))
Пример #5
0
def view(id):
    album = get_model().read(id)
    return render_template("view.html", album=album)