Beispiel #1
0
def home(request):
    featured_badges = map(fetch_badge_resources, badge_api.get_featured_badges())

    users = p2pu_user_api.get_users()
    paginator = Paginator(users, 16)
    page = request.GET.get('page')
    try:
        users = paginator.page(page)
    except PageNotAnInteger:
        users = paginator.page(1)
    except EmptyPage:
        return HttpResponse(status=404)
    if request.is_ajax():
        return render_to_response('p2pu_user/browse_users.html',
                                  {'users': users},
                                  context_instance=RequestContext(request))

    last_n_projects = project_api.last_n_projects(10)
    for project in last_n_projects:
        fetch_project_resources(project,
                                feedback_list=project_api.get_project_feedback(project['uri']))

    return render_to_response('landing/home.html', {
        'badges': featured_badges,
        'users': users,
        'projects': last_n_projects,
    }, context_instance=RequestContext(request))
Beispiel #2
0
    def test_get_users(self):
        user = user_api.save_user('testuser1', 'http://placehold.it/40x40')
        user = user_api.save_user('testuser2', 'http://placehold.it/20x20')
        user = user_api.save_user('testuser1', 'http://placehold.it/40x40')

        user_list = user_api.get_users()
        self.assertEqual(len(user_list), 2)
Beispiel #3
0
def home(request):
    context = {}
    context['badges'] = map(fetch_badge_resources, badge_api.get_published_badges())[-5:]
    context['projects'] = map(fetch_project_resources, project_api.get_projects())[-10:]
    context['users'] = p2pu_user_api.get_users()[-20:]
    
    return render_to_response('landing/home.html', context, context_instance=RequestContext(request))