Ejemplo n.º 1
0
def detail(request, username=None):
    """
    Renders information about a single user's profile.  This includes
    information about who follows them, who they follow, mutual followers, the
    latest events created, and whether the currently logged in user is a friend
    of the user to render.
    """
    user = get_object_or_404(User, username=username)
    events_created = list(Event.objects.filter(creator=user, latest=True).order_by('-creation_date')[:10])
    attended = Attendance.objects.filter(user=user).order_by('-registration_date')[:10]
    events_attended = list(Event.objects.filter(id__in=[e.event.id for e in attended]).order_by('-creation_date'))
    people_following_user = get_people_following_user(user)
    context = {
        'profile_user': user,
        'people_following_user': people_following_user,
        'people_user_follows': get_people_user_follows(user),
        'mutual_followers': get_mutual_followers(user),
        'events_created': events_created,
        'num_events_created': len(events_created),
        'events_attended': events_attended,
        'num_events_attended': len(events_attended),
        'friend': request.user in people_following_user,
    }
    return render_to_response(
        'profile/detail.html',
        context,
        context_instance = RequestContext(request)
    )
    
Ejemplo n.º 2
0
def find_and_add(request):
    """
    A page for finding and adding new friends to follow.  Right now this
    consists solely of a search box, which given input, renders a list of
    users who match the search terms.
    """
    search_form = SearchForm(request.GET or None)
    context = {
        'search_form': search_form,
    }
    if search_form.is_valid():
        q = search_form.cleaned_data['q']
        context['q'] = q
        users = User.objects.filter(username__icontains=q) | User.objects.filter(
            email__icontains=q)
    else:
        users = []
    friends = get_people_user_follows(request.user)
    users = [(u, u in friends) for u in users]
    context['users'] = users
    context['user_count'] = len(users)
    return render_to_response(
        'socialgraph/find_add.html',
        context,
        context_instance = RequestContext(request)
    )
Ejemplo n.º 3
0
 def render(self, context):
     try:
         user = template.resolve_variable(self.user, context)
     except template.VariableDoesNotExist:
         return ''
     context[self.context_var] = dict([(u.username, u) for u in 
         get_people_user_follows(user)])
     return ''
Ejemplo n.º 4
0
 def render(self, context):
     try:
         user = template.resolve_variable(self.user, context)
     except template.VariableDoesNotExist:
         return ''
     context[self.context_var] = dict([
         (u.username, u) for u in get_people_user_follows(user)
     ])
     return ''
Ejemplo n.º 5
0
def detail(request, username=None):
    """
    Renders information about a single user's profile.  This includes
    information about who follows them, who they follow, mutual followers, the
    latest events created, and whether the currently logged in user is a friend
    of the user to render.
    """
    user = get_object_or_404(User, username=username)
    people_following_user = get_people_following_user(user)
    context = {
        'profile_user': user,
        'people_following_user': people_following_user,
        'people_user_follows': get_people_user_follows(user),
        'mutual_followers': get_mutual_followers(user),
        'friend': request.user in people_following_user,
    }
    return render_to_response(
        'profile/detail.html',
        context,
        context_instance = RequestContext(request)
    )
    
Ejemplo n.º 6
0
def find_and_add(request):
    """
    A page for finding and adding new friends to follow.  Right now this
    consists solely of a search box, which given input, renders a list of
    users who match the search terms.
    """
    search_form = SearchForm(request.GET or None)
    context = {
        'search_form': search_form,
    }
    if search_form.is_valid():
        q = search_form.cleaned_data['q']
        context['q'] = q
        users = User.objects.filter(
            username__icontains=q) | User.objects.filter(email__icontains=q)
    else:
        users = []
    friends = get_people_user_follows(request.user)
    users = [(u, u in friends) for u in users]
    context['users'] = users
    context['user_count'] = len(users)
    return render_to_response('socialgraph/find_add.html',
                              context,
                              context_instance=RequestContext(request))