def edit_newsletter(request, key): newsletter = Newsletter.get(key) form = AddNewsletter(instance=newsletter) if request.method == "POST" and request.form and form.validate(request.form, request.files): newsletter = form.save(commit=False) newsletter.put() return redirect("/admin/postman/newsletters/") files = [] for file_key in newsletter.n_price_list: file_ = File.get(file_key) if file_: files.append(file_) return render_to_response( "postman/admin/newsletters/edit.html", {"form": form.as_widget(), "key": key, "files": files} )
def add_newsletter(request): form = AddNewsletter() if request.method == "POST" and form.validate(request.form): newsletter = form.save() return redirect("/admin/postman/newsletters/edit/%s/" % newsletter.key()) return render_to_response("postman/admin/newsletters/add.html", {"form": form.as_widget()})