示例#1
0
文件: views.py 项目: braskin/pd
def view_child_profile(request, child_id, **kwargs):

    child = Child.objects.select_related('photo','album','school').get(id=child_id)
    
    cv = ChildView(user=request.user, child=child)
    if not cv.can_view_child_extended_profile:
        raise Exception('No permissions to view this child\'s profile page')

    photos = None    
    if cv.can_view_child_photos:
        photos = get_photos_for_children([ child ], 3)


    ctx = {        
        'childview':cv,
        'can_edit_profile': cv.can_edit_child_playlist,
        'can_view_calendar': cv.can_view_child_schedule,
        'key':cv.key(),
        'my_child':cv.is_child_mine,
        'photos':photos,
    }

    
    template = "profiles/child_profile.html"
    return render_to_response(template, RequestContext(request, ctx))
示例#2
0
文件: views.py 项目: braskin/pd
def view(request, user_id = None, **kwargs):

#    messages.add_message(request, messages.INFO, 'a message')

    me = False
    if user_id is None:
        user = request.user
        me = True
    else:
        user = User.objects.select_related('_profile_cache').get(id=user_id)
        if user == request.user:
            me = True

    # request.owner's children (for adding to playlist)

    # owner of currently viewed profile display children

    manage_playlist_children = get_cv_list_from_ac(request.user, request.user.get_profile().manage_playlist_children)

    
    display_children = get_cv_list_from_ac(request.user, user.get_profile().display_children)  

    view_playlist_children = []

    # those owner display children whose playlists we can see
    for cv in display_children:
        if cv.can_view_child_playlist:
            view_playlist_children.append(cv)

    view_photos_children = []
    for cv in display_children:
        if cv.can_view_child_photos:
            view_photos_children.append(cv.child)

    photos = []
    if len(view_photos_children):
        photos = get_photos_for_children(view_photos_children, 3)

    ctx = {
        'profile':user.get_profile(),
        'display_children':display_children,
        'view_playlist_children':view_playlist_children,
        'manage_playlist_children':manage_playlist_children,
        'photos':photos,
        'me': me,
        'cat_profile':True,
    }
    
    template = "profiles/view_profile.html"
    return render_to_response(template, RequestContext(request, ctx))