def edit(id): """ Webpage form is called to edit a movie review. POST requests will process the form to edit the movie review and return to the list page. """ moviereview = get_model().read(id) if request.method == 'POST': data = request.form.to_dict(flat=True) moviereview = get_model().update(data, id) return redirect(url_for('.list', id=moviereview['id'])) return render_template("form.html", action="Edit", moviereview=moviereview)
def list(): """ Displays all the movie reviews within a webpage. """ token = request.args.get('page_token', None) moviereviews, next_page_token = get_model().list(cursor=token) return render_template("list.html", moviereviews=moviereviews, next_page_token=next_page_token)
def add(): """ Webpage form is called to add a new movie review. POST requests will process the form and return to the list page. """ if request.method == 'POST': data = request.form.to_dict(flat=True) moviereview = get_model().create(data) return redirect(url_for('.list', id=moviereview['id'])) return render_template("form.html", action="Add", moviereview={})
def delete(id): """ View webpage function to delete a movie review. Movie review id is used to delete the review from the Datastore and return to the list page. """ get_model().delete(id) return redirect(url_for('.list'))
def view(id): """ Webpage to view individual movie reviews. """ moviereview = get_model().read(id) return render_template("view.html", moviereview=moviereview)