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 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)
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 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={})
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)