Example #1
0
def edit_album(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":
        # Collect the form details.
        new_name    = request.form["name"]
        description = request.form["description"]
        layout      = request.form["format"]

        # Renaming the album?
        if new_name != album:
            ok = Photo.rename_album(album, new_name)
            if not ok:
                flash("Failed to rename album: already exists?")
                return redirect(url_for(".edit_album", album=album))
            album = new_name

        # Update album settings.
        Photo.edit_album(album, dict(
            description=description,
            format=layout,
        ))

        return redirect(url_for(".albums"))

    g.info["album"] = album
    g.info["album_info"] = Photo.get_album(album)
    g.info["photos"] = photos

    return template("photos/edit_album.html")
Example #2
0
def album_index(name):
    """View the photos inside an album."""
    photos = Photo.list_photos(name)
    if photos is None:
        flash("That album doesn't exist.")
        return redirect(url_for(".albums"))

    g.info["album"]      = name
    g.info["album_info"] = Photo.get_album(name)
    g.info["markdown"]   = render_markdown(g.info["album_info"]["description"])
    g.info["photos"]     = photos

    # Render Markdown descriptions for photos.
    for photo in g.info["photos"]:
        photo["data"]["markdown"] = render_markdown(photo["data"].get("description", ""))

    return template("photos/album.html")