示例#1
0
def userlists():
    """ A page displaying all lists belonging to the user. """

    current_user = flask_security.core.current_user
    cur_user_nat_id = current_user.id  # the natively used id for the user,
    # since we're querying reference fields
    lists = (
        Catalist.objects(
            db.Q(creator=current_user.uid)
            | db.Q(owners=current_user.id)
            | db.Q(editors=current_user.id)
            | db.Q(viewers=current_user.id)
            | db.Q(mylisters=current_user.id)
        )
        .only("listid", "title", "last_visited")
        .all()
    )
    if lists.first() is None:
        return render_template("home.html", message="Oops! You have no lists saved! " + "Would you like to create one?")

    lists = lists.order_by("-last_visited").all()
    return render_template("mylists.html", lists=lists, host=HOSTNAME)