Merge branch 'master' of ssh://git.onelab.eu/git/myslice
authorYasin <mohammed-yasin.rahman@lip6.fr>
Tue, 17 Dec 2013 10:51:24 +0000 (11:51 +0100)
committerYasin <mohammed-yasin.rahman@lip6.fr>
Tue, 17 Dec 2013 10:51:24 +0000 (11:51 +0100)
16 files changed:
portal/dashboardview.py
portal/platformsview.py
portal/platformview.py
portal/portalpage.py
portal/registrationview.py
portal/resourceview.py
portal/sliceview.py
portal/views.py
sample/dashboardview.py
sample/pluginview.py
sample/querygridview.py
sample/querytableview.py
sample/tabview.py
sample/topmenuvalidationview.py
sandbox/views.py
unfold/page.py

index 95abbaf..2f04a40 100644 (file)
@@ -75,7 +75,6 @@ class DashboardView (LoginRequiredAutoLogoutView):
         context['username'] = the_user(self.request) 
 
         page.expose_js_metadata()
-        page.expose_queries()
 
         # the page header and other stuff
         context.update(page.prelude_env())
index 6744643..7e7d53a 100644 (file)
@@ -2,7 +2,7 @@ from manifold.core.query         import Query
 from unfold.page                 import Page
 
 from unfold.loginrequired       import FreeAccessView
-from ui.topmenu                  import topmenu_items, the_user
+from ui.topmenu                  import topmenu_items_live, the_user
 
 from plugins.querytable          import QueryTable
 
@@ -18,7 +18,6 @@ class PlatformsView(FreeAccessView):
         page.enqueue_query(platform_query)
 
         page.expose_js_metadata()
-        page.expose_queries()
         platformlist = QueryTable(
             page  = page,
             title = 'List',
@@ -42,7 +41,7 @@ class PlatformsView(FreeAccessView):
         # more general variables expected in the template
         context['title'] = 'Platforms connected to MySlice'
         # the menu items on the top
-        context['topmenu_items'] = topmenu_items('Platforms', self.request)
+        context['topmenu_items'] = topmenu_items_live('Platforms', page)
         # so we can sho who is logged
         context['username'] = the_user(self.request)
 
index f3ea7f7..86d282b 100644 (file)
@@ -2,7 +2,7 @@ from manifold.core.query         import Query
 from unfold.page                 import Page
 
 from unfold.loginrequired        import FreeAccessView
-from ui.topmenu                  import topmenu_items, the_user
+from ui.topmenu                  import topmenu_items_live, the_user
 
 from plugins.querytable          import QueryTable
 
@@ -24,7 +24,6 @@ class PlatformView(FreeAccessView):
         page.enqueue_query(network_query)
 
         page.expose_js_metadata()
-        page.expose_queries()
         networklist = QueryTable(
             page  = page,
             title = 'List',
@@ -54,7 +53,7 @@ class PlatformView(FreeAccessView):
         # more general variables expected in the template
         context['title'] = 'Platforms connected to MySlice'
         # the menu items on the top
-        context['topmenu_items'] = topmenu_items('Platforms', self.request)
+        context['topmenu_items'] = topmenu_items_live('Platforms', page)
         # so we can sho who is logged
         context['username'] = the_user(self.request)
 
index f592444..2023e4f 100644 (file)
@@ -29,6 +29,8 @@ class PortalPage(Page):
         # Jordan: it seems we need this to init plugins js
         # Issue a "manifold is not defined" error
         #self.expose_queries ()
+        # Thierry: this is deprecated anyway, and will happen as part of prelude_env
+        # "manifold not defined" would be due to a missing dependency to manifold.js or something...
 
         template_env.update(self.prelude_env())
         result=render_to_response ('view-unfold1.html',template_env,
index 8f91de7..0002bf4 100644 (file)
@@ -9,7 +9,7 @@ from django.shortcuts           import render
 
 from unfold.page                import Page
 from unfold.loginrequired       import FreeAccessView
-from ui.topmenu                 import topmenu_items
+from ui.topmenu                 import topmenu_items_live
 
 from manifold.manifoldapi       import execute_admin_query
 from manifold.core.query        import Query
@@ -168,7 +168,7 @@ class RegistrationView (FreeAccessView):
                 return render(request, 'user_register_complete.html') 
 
         template_env = {
-          'topmenu_items': topmenu_items('Register', request),
+          'topmenu_items': topmenu_items_live('Register', page),
           'errors': errors,
           'firstname': request.POST.get('firstname', ''),
           'lastname': request.POST.get('lastname', ''),
index 155eff3..3ed9dcc 100644 (file)
@@ -2,7 +2,7 @@ from manifold.core.query        import Query
 from unfold.page                import Page
 
 from unfold.loginrequired       import FreeAccessView
-from ui.topmenu                 import topmenu_items, the_user
+from ui.topmenu                 import topmenu_items_live, the_user
 
 from plugins.googlemap          import GoogleMap
 from plugins.querytable         import QueryTable
@@ -31,7 +31,6 @@ class ResourceView(FreeAccessView):
         page.enqueue_query(resource_query)
 
         page.expose_js_metadata()
-        page.expose_queries()
 
         resourcelist = QueryTable(
             page  = page,
@@ -86,7 +85,7 @@ class ResourceView(FreeAccessView):
         # more general variables expected in the template
         context['title'] = 'Information about a resource'
         # the menu items on the top
-        context['topmenu_items'] = topmenu_items(None, self.request)
+        context['topmenu_items'] = topmenu_items_live(None, page)
         # so we can sho who is logged
         context['username'] = the_user(self.request)
 
index b9ac8b1..db25e64 100644 (file)
@@ -433,7 +433,6 @@ class SliceView (LoginRequiredAutoLogoutView):
     
         # don't forget to run the requests
         page.expose_js_metadata()
-        page.expose_queries ()
         # the prelude object in page contains a summary of the requirements() for all plugins
         # define {js,css}_{files,chunks}
         template_env.update(page.prelude_env())
index d454502..3a71907 100644 (file)
@@ -28,7 +28,7 @@ from django.shortcuts           import render
 from django.template.loader     import render_to_string
 
 from unfold.loginrequired       import FreeAccessView
-from ui.topmenu                 import topmenu_items, the_user
+from ui.topmenu                 import topmenu_items_live, the_user
 
 from portal.event               import Event
 # presview is put in observation for now
@@ -68,7 +68,7 @@ class PresViewView(FreeAccessView):
         # more general variables expected in the template
         context['title'] = 'Test view that combines various plugins'
         # the menu items on the top
-        context['topmenu_items'] = topmenu_items('PresView', self.request)
+        context['topmenu_items'] = topmenu_items_live('PresView', page)
         # so we can sho who is logged
         context['username'] = the_user(self.request)
 
index f4bde8f..18438d8 100644 (file)
@@ -19,7 +19,7 @@ from plugins.quickfilter import QuickFilter
 from trash.trashutils import quickfilter_criterias
 
 # 
-from ui.topmenu import topmenu_items, the_user
+from ui.topmenu import topmenu_items_live, the_user
 
 @login_required
 def dashboard_view (request):
@@ -71,7 +71,7 @@ def dashboard_view (request):
     # more general variables expected in the template
     template_env [ 'title' ] = 'Test view for a full request cycle'
     # the menu items on the top 
-    template_env [ 'topmenu_items' ] = topmenu_items('dashboard', request
+    template_env [ 'topmenu_items' ] = topmenu_items_live('dashboard', page
     # so we can sho who is logged
     template_env [ 'username' ] = the_user (request) 
 
@@ -92,12 +92,6 @@ def dashboard_view (request):
     # add our own css in the mix
     #page.add_css_files ( 'css/dashboard.css')
     
-    # don't forget to run the requests
-    page.expose_queries ()
-
-    # xxx create another plugin with the same query and a different layout (with_datatables)
-    # show that it worls as expected, one single api call to backend and 2 refreshed views
-
     # the prelude object in page contains a summary of the requirements() for all plugins
     # define {js,css}_{files,chunks}
     prelude_env = page.prelude_env()
index f200312..144115e 100644 (file)
@@ -19,7 +19,7 @@ from plugins.raw                        import Raw
 from plugins.messages                   import Messages
 from plugins.querytable                 import QueryTable
 
-from ui.topmenu                         import topmenu_items, the_user
+from ui.topmenu                         import topmenu_items_live, the_user
 from trash.trashutils                   import hard_wired_slice_names, hard_wired_list, lorem_p, lorem, quickfilter_criterias
 
 #might be useful or not depending on the context
@@ -89,12 +89,9 @@ $(function(){$("#bouton").click(issue_debug);});
 
     # more general variables expected in the template
     template_env [ 'title' ] = 'Single Plugin View' 
-    template_env [ 'topmenu_items' ] = topmenu_items('plugin', request
+    template_env [ 'topmenu_items' ] = topmenu_items_live('plugin', page
     template_env [ 'username' ] = the_user (request) 
 
-    # run queries when we have any
-    page.expose_queries ()
-
     # the prelude object in page contains a summary of the requirements() for all plugins
     # define {js,css}_{files,chunks}
     prelude_env = page.prelude_env()
index ef8d993..0e2fc8e 100644 (file)
@@ -7,7 +7,7 @@ from manifold.core.query import Query, AnalyzedQuery
 
 from unfold.page import Page
 
-from ui.topmenu import topmenu_items, the_user
+from ui.topmenu import topmenu_items_live, the_user
 
 from plugins.querygrid import QueryGrid
 
@@ -69,13 +69,10 @@ class QueryGridView (TemplateView):
         # more general variables expected in the template
         template_env [ 'title' ] = 'simple %(slicename)s'%locals()
         # the menu items on the top
-        template_env [ 'topmenu_items' ] = topmenu_items('Slice', request
+        template_env [ 'topmenu_items' ] = topmenu_items_live('Slice', page
         # so we can sho who is logged
         template_env [ 'username' ] = the_user (request) 
     
-        # don't forget to run the requests
-        page.expose_queries ()
-
         # the prelude object in page contains a summary of the requirements() for all plugins
         # define {js,css}_{files,chunks}
         prelude_env = page.prelude_env()
index 2e08abc..25cb6a0 100644 (file)
@@ -7,7 +7,7 @@ from manifold.core.query import Query, AnalyzedQuery
 
 from unfold.page import Page
 
-from ui.topmenu import topmenu_items, the_user
+from ui.topmenu import topmenu_items_live, the_user
 
 from plugins.querytable import QueryTable
 
@@ -68,13 +68,10 @@ class QueryTableView (TemplateView):
         # more general variables expected in the template
         template_env [ 'title' ] = 'simple %(slicename)s'%locals()
         # the menu items on the top
-        template_env [ 'topmenu_items' ] = topmenu_items('Slice', request
+        template_env [ 'topmenu_items' ] = topmenu_items_live('Slice', page
         # so we can sho who is logged
         template_env [ 'username' ] = the_user (request) 
     
-        # don't forget to run the requests
-        page.expose_queries ()
-
         # the prelude object in page contains a summary of the requirements() for all plugins
         # define {js,css}_{files,chunks}
         prelude_env = page.prelude_env()
index 167788e..95c4828 100644 (file)
@@ -14,14 +14,14 @@ def tab_view (request):
     print "request", request.__class__
     print request
     prelude=Prelude( js_files='js/bootstrap.js', css_files='css/bootstrap.css')
-    prelude_env = prelude.prelude_env()
 
     tab_env = {'title':'Page for playing with Tabs',
                'topmenu_items': topmenu_items('tab',request),
                'username':the_user (request),
                'lorem': lorem,                                
                }
-    tab_env.update (prelude_env)
+
+    tab_env.update (prelude.prelude_env())
     return render_to_response ('view-tab.html', tab_env,
                                context_instance=RequestContext(request))
 
index 27b420e..506423c 100644 (file)
@@ -31,9 +31,6 @@ class TopmenuValidationView (TemplateView):
         # so we can see who is logged
         template_env [ 'username' ] = the_user (request) 
     
-        # don't forget to run the requests
-        page.expose_queries ()
-
         # the prelude object in page contains a summary of the requirements() for all plugins
         # define {js,css}_{files,chunks}
         prelude_env = page.prelude_env()
index 707e8f7..6e1e152 100644 (file)
@@ -29,7 +29,7 @@ from django.template.loader     import render_to_string
 from manifold.core.query        import Query
 from plugins.myplugin           import MyPlugin
 from plugins.maddash            import MadDash
-from ui.topmenu                 import topmenu_items, the_user
+from ui.topmenu                 import topmenu_items_live, the_user
 from unfold.loginrequired       import FreeAccessView
 from unfold.page                import Page
 
@@ -52,7 +52,7 @@ class MyPluginView(FreeAccessView):
         # more general variables expected in the template
         context['title'] = 'Sandbox for MyPlugin plugin'
         # the menu items on the top
-        context['topmenu_items'] = topmenu_items('myplugin', self.request)
+        context['topmenu_items'] = topmenu_items_live('myplugin', page)
         # so we can sho who is logged
         context['username'] = the_user(self.request)
 
@@ -85,7 +85,7 @@ class MadDashView(FreeAccessView):
         context = super(MadDashView, self).get_context_data(**kwargs)
         context['unfold_main'] = plugin.render(self.request)
         context['title'] = 'Sandbox for MadDash plugin'
-        context['topmenu_items'] = topmenu_items('maddash', self.request)
+        context['topmenu_items'] = topmenu_items_live ('maddash', page)
         context['username'] = the_user(self.request)
 
         prelude_env = page.prelude_env()
index 87a3bfb..834be7e 100644 (file)
@@ -49,7 +49,7 @@ class Page:
 #        self._queue = []
 
     # this method adds a query to the page
-    # the query will be exposed to js when calling expose_queries
+    # the query will be exposed to js when calling __expose_queries, which is done by prelude_env() 
     # additionally if run_it is set to True, this query will be asynchroneously triggered on page load
     # in this case (exec=True) the js async callback (see manifold.asynchroneous_success)
     # offers the option to deliver the result to a specific DOM elt (in this case, set domid)
@@ -73,11 +73,11 @@ class Page:
         self.add_js_files('js/record_generator.js');
         js_chunk = '$(document).ready(function() { new RecordGenerator(%s,%s,%s).run(); });'%(query.to_json(),json.dumps(generators),number);
         self.add_js_chunks(js_chunk)
-
+    
     # return the javascript code for exposing queries
     # all queries are inserted in the global manifold object
     # in addition, the ones enqueued with 'run_it=True' are triggered 
-    def expose_queries (self):
+    def __expose_queries (self):
         # compute variables to expose to the template
         env = {}
         # expose the json definition of all queries
@@ -139,5 +139,9 @@ class Page:
     def add_js_chunks (self):pass
     @to_prelude
     def add_css_chunks (self):pass
-    @to_prelude
-    def prelude_env (self):pass
+
+    # prelude_env also does expose_queries
+    def prelude_env (self):
+        self.__expose_queries()
+        from_prelude=self.prelude.prelude_env()
+        return from_prelude