1 # Create your views here.
3 from django.template import RequestContext
4 from django.shortcuts import render_to_response
6 from django.contrib.auth.decorators import login_required
8 from unfold.page import Page
9 from manifold.manifoldquery import ManifoldQuery
11 from plugins.stack.stack import Stack
12 from plugins.tabs.tabs import Tabs
13 from plugins.hazelnut.hazelnut import Hazelnut
14 from plugins.lists.slicelist import SliceList
15 from plugins.querycode.querycode import QueryCode
16 from plugins.quickfilter.quickfilter import QuickFilter
18 from myslice.viewutils import quickfilter_criterias
20 from myslice.viewutils import topmenu_items, the_user
22 tmp_default_slice='ple.inria.sfatest'
25 def slice_view (request, slicename=tmp_default_slice):
29 main_query = ManifoldQuery (action='get',
32 fields=['hrn','hostname'],
33 filters= [ [ 'slice_hrn', '=', slicename, ] ],
34 # xxx filter : should filter on the slices the logged user can see
35 # we don't have the user's hrn yet
36 # in addition this currently returns all slices anyways
40 page.enqueue_query (main_query)
44 title="global container",
48 title="different angles",
49 active_domid='with-checkboxes',
53 title='a sample and simple hazelnut',
55 # this is the query at the core of the slice list
60 title='with checkboxes',
61 domid='with-checkboxes',
64 # this is the query at the core of the slice list
76 # variables that will get passed to the view-plugin.html template
79 # define 'unfold2_main' to the template engine
80 template_env [ 'unfold1_main' ] = main_plugin.render(request)
82 # more general variables expected in the template
83 template_env [ 'title' ] = 'Test view for hazelnut'
84 # the menu items on the top
85 template_env [ 'topmenu_items' ] = topmenu_items('slice', request)
86 # so we can sho who is logged
87 template_env [ 'username' ] = the_user (request)
89 ### # ########## add another plugin with the same request, on the RHS pane
90 ### # will show up in the right-hand side area named 'related'
91 ### related_plugin = SliceList (
93 ### title='Same request, other layout',
95 ### with_datatables=True,
96 ### header='paginated main',
100 ### # likewise but on the side view
101 ### template_env [ 'unfold2_margin' ] = related_plugin.render (request)
103 ### # add our own css in the mix
104 ### page.add_css_files ( 'css/hazelnut.css')
106 # don't forget to run the requests
107 page.exec_queue_asynchroneously ()
109 # xxx create another plugin with the same query and a different layout (with_datatables)
110 # show that it worls as expected, one single api call to backend and 2 refreshed views
112 # the prelude object in page contains a summary of the requirements() for all plugins
113 # define {js,css}_{files,chunks}
114 prelude_env = page.prelude_env()
115 template_env.update(prelude_env)
116 result=render_to_response ('view-slice.html',template_env,
117 context_instance=RequestContext(request))
118 print 'result=',result