示例#1
0
def delete_album(album):
    """Delete an entire album."""
    photos = Photo.list_photos(album)
    if photos is None:
        flash("That album doesn't exist.")
        return redirect(url_for(".albums"))

    if request.method == "POST":
        # Do it.
        for photo in photos:
            Photo.delete_photo(photo["key"])
        flash("The album has been deleted.")
        return redirect(url_for(".albums"))

    g.info["album"] = album

    return template("photos/delete_album.html")
示例#2
0
def delete(key):
    """Delete a photo."""
    pic = Photo.get_photo(key)
    if not pic:
        flash("The photo wasn't found!")
        return redirect(url_for(".albums"))

    if request.method == "POST":
        # Do it.
        Photo.delete_photo(key)
        flash("The photo has been deleted.")
        return redirect(url_for(".albums"))

    g.info["key"] = key
    g.info["photo"] = pic

    return template("photos/delete.html")