def updateURL(request, key): if not admin(): return HttpResponseRedirect(users.create_login_url("/blogs")) form = URLForm(request.POST) if form.is_valid(): friendlyURL = FriendlyURL.get(key) friendlyURL.name = form.cleaned_data["name"] friendlyURL.URL = form.cleaned_data["URL"] friendlyURL.put() return HttpResponseRedirect("/blogs") else: return editURL(request, key)
def editURL(request, key): context = base_context() if not admin(): return HttpResponseRedirect(users.create_login_url("/blogs")) friendlyURL = FriendlyURL.get(key) if request.method == "POST": form = URLForm(request.POST) else: form = URLForm() form.fields["name"].initial = friendlyURL.name form.fields["URL"].initial = friendlyURL.URL context.friendlyURL = friendlyURL context.form = form template = loader.get_template("blogs/editURL.html") return HttpResponse(template.render(context))
def deleteURL(request, key): if not admin(): return HttpResponseRedirect(users.create_login_url("/blogs")) friendlyURL = FriendlyURL.get(key) friendlyURL.delete() return HttpResponseRedirect("/blogs")