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