little optimisation from maintenance head
authorcavaliet
Thu, 18 Apr 2013 13:25:59 +0200
changeset 1157 4133f4c57ec8
parent 1155 ab32721c18b9
child 1165 4ca7ed5c7634
little optimisation from maintenance head
src/ldt/ldt/ldt_utils/views/front.py
--- a/src/ldt/ldt/ldt_utils/views/front.py	Mon Apr 15 17:03:50 2013 +0200
+++ b/src/ldt/ldt/ldt_utils/views/front.py	Thu Apr 18 13:25:59 2013 +0200
@@ -56,11 +56,13 @@
     
     # Get the active group
     group = Group.objects.select_related("profile").get(id=group_id)
+    proj_title = request.GET.get("title")
     # Get the projects for this group
     project_list = get_group_projects(request.user, group_id, False, False)
-    proj_title = request.GET.get("title")
-    if proj_title is not None:
-        project_list = project_list.filter(title__icontains=proj_title)
+    if not type(project_list) is list:
+        project_list = project_list.prefetch_related('contents').select_related("owner").filter(state=2)
+        if proj_title is not None:
+            project_list = project_list.filter(title__icontains=proj_title)
     
     nb = settings.LDT_FRONT_PROJECTS_PER_PAGE
     page = request.GET.get("page") or 1
@@ -73,10 +75,6 @@
     except (EmptyPage, InvalidPage):
         results = paginator.page(paginator.num_pages)
     
-    ## list of contents annotated by the group (or everyone)
-    #everyone = Group.objects.get(name=settings.PUBLIC_GROUP_NAME)
-    #content_list = get_objects_for_group(group, 'ldt_utils.view_content') | get_objects_for_group(everyone, 'ldt_utils.view_content')
-    
     # Group's users
     users = User.objects.filter(groups__in=[group]).exclude(is_superuser=True)