Esempio n. 1
0
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)
Esempio n. 2
0
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))
Esempio n. 3
0
def deleteURL(request, key):
    if not admin():
        return HttpResponseRedirect(users.create_login_url("/blogs"))
    friendlyURL = FriendlyURL.get(key)
    friendlyURL.delete()
    return HttpResponseRedirect("/blogs")