Exemplo n.º 1
0
def home(request):
    # Get the 10 most popular projects
    projects_popular = Project.approved_projects().all().annotate(num_votes=Count('votes')).order_by('-num_votes')[:10]
    # Get the 10 newest
    projects_newest = Project.approved_projects().all().order_by('-id')[:10]
    return render_to_response('home.html', {
        "form": AuthenticationForm(),
        'projects_popular': projects_popular,
        'projects_newest': projects_newest
    }, context_instance=RequestContext(request))
Exemplo n.º 2
0
 def get_queryset(self):
     set = Project.approved_projects()
     filter_val = self.request.GET.get('filter')
     if filter_val is not None:
        set = set.filter(application=filter_val,)
     order = self.request.GET.get('orderby')
     if order is not None:
        set = set.order_by(order)
     return set
Exemplo n.º 3
0
def home(request):
    """Get the 10 most popular projects *dead*, Get the 10 newest."""
    projects_newest = Project.approved_projects().all().select_related("screenshot").order_by('-id')[:10]
    projects_newest = [project for project in projects_newest]
    return render(request, 'home.html', {
        "form": AuthenticationForm(),
        'projects_popular': projects_newest,
        'projects_newest': projects_newest
    })
Exemplo n.º 4
0
def home(request):
    # Get the 10 most popular projects
    # Get the 10 newest
    projects_newest = Project.approved_projects().all().order_by('-id')[:10]
    return render(
        request, 'home.html', {
            "form": AuthenticationForm(),
            'projects_popular': projects_newest,
            'projects_newest': projects_newest
        })
Exemplo n.º 5
0
 def get_queryset(self):
     self.tag = get_object_or_404(Tag, pk=self.kwargs['tag_pk'])
     return Project.approved_projects().filter(tags__in=[self.tag])
Exemplo n.º 6
0
 def test_only_shows_published_projects(self):
     projects = Project.approved_projects().all()
     for project in projects:
         self.assertTrue(project.approved)
Exemplo n.º 7
0
 def get_queryset(self):
     """Order projects based on filter or order request settings."""
     queryset = Project.approved_projects()
     return filter_project_query(queryset,
                                 self.request).select_related("screenshot")
Exemplo n.º 8
0
 def get_queryset(self):
     """Order projects based on filter or order request settings."""
     queryset = Project.approved_projects()
     return filter_project_query(queryset, self.request)