keep only import topmenu_items, the_user in myslice/viewutils
[myslice.git] / trash / sliceview.py
index 632aec4..534ed78 100644 (file)
@@ -9,7 +9,9 @@ from unfold.page                     import Page
 from manifold.core.query             import Query, AnalyzedQuery
 from manifold.manifoldresult         import ManifoldException
 from manifold.metadata               import MetaData as Metadata
 from manifold.core.query             import Query, AnalyzedQuery
 from manifold.manifoldresult         import ManifoldException
 from manifold.metadata               import MetaData as Metadata
-from myslice.viewutils               import quickfilter_criterias, topmenu_items, the_user
+# need to remove this dep.
+from trash.trashutils                import quickfilter_criterias
+from myslice.viewutils               import topmenu_items, the_user
 
 from plugins.raw.raw                 import Raw
 from plugins.stack.stack             import Stack
 
 from plugins.raw.raw                 import Raw
 from plugins.stack.stack             import Stack
@@ -24,7 +26,7 @@ from plugins.query_editor            import QueryEditor
 from plugins.active_filters          import ActiveFilters
 from plugins.quickfilter.quickfilter import QuickFilter
 from plugins.messages.messages       import Messages
 from plugins.active_filters          import ActiveFilters
 from plugins.quickfilter.quickfilter import QuickFilter
 from plugins.messages.messages       import Messages
-from plugins.updater                 import Updater
+#from plugins.updater                 import Updater
 
 tmp_default_slice='ple.upmc.myslicedemo'
 debug = True
 
 tmp_default_slice='ple.upmc.myslicedemo'
 debug = True
@@ -58,6 +60,9 @@ def _slice_view (request, slicename):
     resource_md = metadata.details_by_object('resource')
     resource_fields = [column['name'] for column in resource_md['column']]
 
     resource_md = metadata.details_by_object('resource')
     resource_fields = [column['name'] for column in resource_md['column']]
 
+    user_md = metadata.details_by_object('user')
+    user_fields = ['user_hrn'] # [column['name'] for column in user_md['column']]
+
     # TODO The query to run is embedded in the URL
     main_query = Query.get('slice').filter_by('slice_hrn', '=', slicename)
     main_query.select(
     # TODO The query to run is embedded in the URL
     main_query = Query.get('slice').filter_by('slice_hrn', '=', slicename)
     main_query.select(
@@ -69,10 +74,12 @@ def _slice_view (request, slicename):
     )
 
     query_resource_all = Query.get('resource').select(resource_fields)
     )
 
     query_resource_all = Query.get('resource').select(resource_fields)
+    query_user_all = Query.get('user').select(user_fields)
 
     aq = AnalyzedQuery(main_query, metadata=metadata)
     page.enqueue_query(main_query, analyzed_query=aq)
     page.enqueue_query(query_resource_all)
 
     aq = AnalyzedQuery(main_query, metadata=metadata)
     page.enqueue_query(main_query, analyzed_query=aq)
     page.enqueue_query(query_resource_all)
+    page.enqueue_query(query_user_all)
 
     # Prepare the display according to all metadata
     # (some parts will be pending, others can be triggered by users).
 
     # Prepare the display according to all metadata
     # (some parts will be pending, others can be triggered by users).
@@ -180,17 +187,6 @@ def _slice_view (request, slicename):
 
     stack_resources.insert(tab_resource_plugins)
 
 
     stack_resources.insert(tab_resource_plugins)
 
-    # --------------------------------------------------------------------------
-    # ResourcesSelected
-    #
-    stack_resources.insert(ResourcesSelected(
-        page                = page,
-        title               = 'Pending operations',
-        resource_query_uuid = sq_resource,
-        lease_query_uuid    = sq_lease,
-        togglable           = True,
-    ))
-
     sq_plugin.insert(stack_resources)
 
     ############################################################################
     sq_plugin.insert(stack_resources)
 
     ############################################################################
@@ -214,6 +210,7 @@ def _slice_view (request, slicename):
         togglable   = False,
         # this is the query at the core of the slice list
         query       = sq_user,
         togglable   = False,
         # this is the query at the core of the slice list
         query       = sq_user,
+        query_all  = query_user_all,
         checkboxes  = True,
         datatables_options = { 
             # for now we turn off sorting on the checkboxes columns this way
         checkboxes  = True,
         datatables_options = { 
             # for now we turn off sorting on the checkboxes columns this way
@@ -253,18 +250,28 @@ def _slice_view (request, slicename):
 
     main_plugin.insert(sq_plugin)
 
 
     main_plugin.insert(sq_plugin)
 
+    # --------------------------------------------------------------------------
+    # ResourcesSelected
+    #
+    main_plugin.insert(ResourcesSelected(
+        page                = page,
+        title               = 'Pending operations',
+        query               = main_query,
+        togglable           = True,
+    ))
+
     main_plugin.insert(Messages(
         page   = page,
         title  = "Runtime messages for slice %s"%slicename,
         domid  = "msgs-pre",
         levels = "ALL",
     ))
     main_plugin.insert(Messages(
         page   = page,
         title  = "Runtime messages for slice %s"%slicename,
         domid  = "msgs-pre",
         levels = "ALL",
     ))
-    main_plugin.insert(Updater(
-        page   = page,
-        title  = "wont show up as non togglable by default",
-        query  = main_query,
-        label  = "Update slice",
-    ))
+#    main_plugin.insert(Updater(
+#        page   = page,
+#        title  = "wont show up as non togglable by default",
+#        query  = main_query,
+#        label  = "Update slice",
+#    ))
     
 
 
     
 
 
@@ -275,7 +282,7 @@ def _slice_view (request, slicename):
     template_env [ 'unfold1_main' ] = main_plugin.render(request)
 
     # more general variables expected in the template
     template_env [ 'unfold1_main' ] = main_plugin.render(request)
 
     # more general variables expected in the template
-    template_env [ 'title' ] = 'Test view that combines various plugins'
+    template_env [ 'title' ] = '%(slicename)s (test view that combines various plugins)'%locals()
     # the menu items on the top
     template_env [ 'topmenu_items' ] = topmenu_items('Slice', request) 
     # so we can sho who is logged
     # the menu items on the top
     template_env [ 'topmenu_items' ] = topmenu_items('Slice', request) 
     # so we can sho who is logged