def details(request, id, template_name="photos/details.html"):
    """
    show the photo details
    """
    photos = Image.objects.all()
    photos = photos.filter(pool__object_id=None)
    

    image_filter = Q(is_public=True)

    if request.user.is_authenticated():
        # allow owner and friend to see a private photo
        image_filter = image_filter | Q(member=request.user) | Q(member__in=friend_set_for(request.user))
        
    try:
        photo = photos.filter(image_filter, id=id)[0]
    except IndexError:                            
        raise Http404
        
    previous_photo_id = get_first_id_or_none(                                             
        photos.filter(image_filter, id__lt=photo.id).order_by('-id')
        )
    
    next_photo_id = get_first_id_or_none(
        photos.filter(image_filter, id__gt=photo.id).order_by('id')
        )         
    
            
    ctx = {
        "photo": photo,
        "photo_url": request.build_absolute_uri(photo.get_display_url()),
        "url": request.build_absolute_uri(),
        "is_me": photo.member == request.user,
        "previous_photo_id": previous_photo_id,
        "next_photo_id": next_photo_id,
    }
    
    return render_to_response(template_name, RequestContext(request, ctx))
dataset/ETHPy150Open amarandon/smeuhsocial/apps/photos/views.py/details/original