src/ldt/ldt/ldt_utils/views/workspace.py
changeset 644 94429061bbfa
parent 602 642b3654b8f1
child 646 97f5db87d71c
--- a/src/ldt/ldt/ldt_utils/views/workspace.py	Wed May 23 17:32:08 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/views/workspace.py	Fri May 25 17:47:20 2012 +0200
@@ -13,9 +13,11 @@
 from ldt.ldt_utils.forms import SearchForm
 from ldt.ldt_utils.models import Content, Project, Segment
 from ldt.ldt_utils.utils import boolean_convert
+from ldt.ldt_utils.projectserializer import ProjectSerializer
+from ldt.ldt_utils.views.content import get_contents_page
+from ldt.ldt_utils.views.project import get_projects_page
 from ldt.security.utils import add_change_attr, get_userlist
 from lxml.html import fragment_fromstring
-from ldt.ldt_utils.projectserializer import ProjectSerializer
 from operator import itemgetter
 from itertools import groupby
 import base64
@@ -27,11 +29,12 @@
 @login_required
 def home(request):
     
-    # list of contents
-    content_list = add_change_attr(request.user, Content.safe_objects.all()) #@UndefinedVariable
-    
+    num_page = 0
+    # Prepare contents pagination
+    content_nb, nb_ct_pages, content_list = get_contents_page(num_page, request.user)
     # get list of projects owned by the current user
-    project_list = add_change_attr(request.user, Project.safe_objects.filter(owner=request.user)) #@UndefinedVariable
+    project_nb, nb_pj_pages, project_list = get_projects_page(num_page, request.user)
+    #project_list = add_change_attr(request.user, Project.safe_objects.filter(owner=request.user)[:settings.LDT_MAX_PROJECTS_PER_PAGE]) #@UndefinedVariable
 
     is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1);
     
@@ -44,12 +47,15 @@
     
     # render list
     return render_to_response("ldt/ldt_utils/workspace.html",
-                              {'contents': content_list, 'projects': project_list,
+                              {'contents': content_list, 'nb_ct_pages': nb_ct_pages, 'content_nb': content_nb, 'current_content_page':float(num_page),
+                               'projects': project_list, 'nb_pj_pages': nb_pj_pages, 'project_nb': project_nb, 'current_project_page':float(num_page),
                                'is_gecko': is_gecko, #'project_api_url':"match.url_name",
                                #'project_api_view':match.url_name,'project_api_args':"project_api_args",'project_api_kwargs':"project_api_kwargs"
                                },
                               context_instance=RequestContext(request))
 
+    
+
 @login_required
 def groups(request): 
 
@@ -245,5 +251,6 @@
 
 def loading(request): 
     return render_to_response('ldt/ldt_utils/loading.html', context_instance=RequestContext(request))
+