def profile_persons():
    # generate a list of (uri, name) choices based on people with profiles on the site
    # NOTE: could filter out anyone with a profile picture, but that would break
    # for editing existing records

    # NOTE: make sure uri is converted to string or else initial value won't match
    choices = [(str(p.identifier), "%s, %s" % (p.lastname, p.firstname)) for p in profile_people()]
    return choices
def site_index(request):
    """Site home page.  Includes a random-order list of profile pictures
    for display at the bottom of the home page.
    """
    pictures = ProfilePicture.objects.all().order_by("?")  # random order
    # find people who have profiles on thes ite
    people = profile_people()
    # filter to only people with a description
    people = [p for p in people if p.has_profile and p.picture]

    return render(request, "pages/site_index.html", {"pictures": pictures, "people": people})
def list(request):
    "Display a list of people one remove from the Belfast Group."
    people = profile_people()
    # filter to only people with a description
    people = [p for p in people if p.has_profile]

    # filter to people with a profile photo loaded, if requested
    # (defaults to true)
    if getattr(settings, "REQUIRE_PROFILE_PICTURE", True):
        people = [p for p in people if p.picture]

    return render(request, "people/list.html", {"people": people})
 def items(self):
     people = profile_people()
     return self.extra_pages + [p for p in people if p.has_profile and p.picture]