From 79b9c7456ed4d38001af597adbf45d022cdea6b1 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 16 Dec 2013 17:28:46 +0100 Subject: [PATCH] now dashboard and sliceview both have the validation plugin this needs some care before we move to all views, because at this point the order in which toplevel_items and expose_queries occur is important, and this is confusing --- portal/dashboardview.py | 17 +++++++++-------- portal/sliceview.py | 14 ++++---------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/portal/dashboardview.py b/portal/dashboardview.py index 41177823..95abbaf9 100644 --- a/portal/dashboardview.py +++ b/portal/dashboardview.py @@ -9,7 +9,7 @@ from plugins.lists.slicelist import SliceList from unfold.loginrequired import LoginRequiredAutoLogoutView -from ui.topmenu import topmenu_items, the_user +from ui.topmenu import topmenu_items_live, the_user #This view requires login class DashboardView (LoginRequiredAutoLogoutView): @@ -29,11 +29,11 @@ class DashboardView (LoginRequiredAutoLogoutView): #slice_query = Query().get('slice').filter_by('user.user_hrn', 'contains', user_hrn).select('slice_hrn') testbed_query = Query().get('network').select('network_hrn','platform') # DEMO GEC18 Query only PLE - user_query = Query().get('local:user').select('config','email') - user_details = execute_query(self.request, user_query) +# user_query = Query().get('local:user').select('config','email') +# user_details = execute_query(self.request, user_query) # not always found in user_details... - config={} +# config={} # for user_detail in user_details: # #email = user_detail['email'] # if user_detail['config']: @@ -50,9 +50,6 @@ class DashboardView (LoginRequiredAutoLogoutView): page.enqueue_query(slice_query) page.enqueue_query(testbed_query) - page.expose_js_metadata() - page.expose_queries() - slicelist = SliceList( page = page, title = "slices", @@ -73,10 +70,14 @@ class DashboardView (LoginRequiredAutoLogoutView): # more general variables expected in the template context['title'] = 'Dashboard' # the menu items on the top - context['topmenu_items'] = topmenu_items('Dashboard', self.request) + context['topmenu_items'] = topmenu_items_live('Dashboard', page) # so we can sho who is logged context['username'] = the_user(self.request) + page.expose_js_metadata() + page.expose_queries() + + # the page header and other stuff context.update(page.prelude_env()) return context diff --git a/portal/sliceview.py b/portal/sliceview.py index 318ee347..b9ac8b19 100644 --- a/portal/sliceview.py +++ b/portal/sliceview.py @@ -59,8 +59,6 @@ class SliceView (LoginRequiredAutoLogoutView): config=Config() page.add_js_chunks ('$(function() { messages.debug("manifold URL %s"); });'%(config.manifold_url())) - page.expose_js_metadata() - metadata = page.get_metadata() resource_md = metadata.details_by_object('resource') resource_fields = [column['name'] for column in resource_md['column']] @@ -434,15 +432,11 @@ class SliceView (LoginRequiredAutoLogoutView): template_env [ 'username' ] = the_user (request) # don't forget to run the requests + page.expose_js_metadata() 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() - template_env.update(prelude_env) - result=render_to_response ('view-unfold1.html',template_env, + template_env.update(page.prelude_env()) + + return render_to_response ('view-unfold1.html',template_env, context_instance=RequestContext(request)) - return result -- 2.43.0