Beispiel #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)
Beispiel #2
0
def edit(id):
    album = get_model().read(id)

    if request.method == 'POST':
        data = request.form.to_dict(flat=True)

        image_url = upload_image_file(request.files.get('image'))
        if image_url:
            data['imageUrl'] = image_url

        album = get_model().update(data, id)
        return redirect(url_for('.view', id=album['id']))

    return render_template("form.html", action="Edit", album=album)
Beispiel #3
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)
Beispiel #4
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={})
Beispiel #5
0
def add():
    if request.method == 'POST':
        data = request.form.to_dict(flat=True)

        image_url = upload_image_file(request.files.get('image'))
        if image_url:
            data['imageUrl'] = image_url

        album = get_model().create(data)
        return redirect(url_for('.view', id=album['id']))

    return render_template("form.html", action="Add", album={})
def add():
    if request.method == 'POST':
        data = request.form.to_dict(flat=True)

        # If an image was uploaded, update the data to point to the new image.
        # [START image_url]
        image_url = upload_image_file(request.files.get('image'))
        # [END image_url]

        # [START image_url2]
        if image_url:
            data['imageUrl'] = image_url
        # [END image_url2]

        album = get_model().create(data)

        return redirect(url_for('.view', id=album['id']))

    return render_template("form.html", action="Add", album={})
Beispiel #7
0
def delete(id):
    get_model().delete(id)
    return redirect(url_for('.list'))
Beispiel #8
0
def view(id):
    album = get_model().read(id)
    return render_template("view.html", album=album)