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",
49 title="2 tabs : w/ and w/o checkboxes",
52 active_domid='checkboxes',
56 title='a sample and simple hazelnut',
59 # this is the query at the core of the slice list
64 title='with checkboxes',
68 # this is the query at the core of the slice list
77 # this is the query at the core of the slice list
88 # variables that will get passed to the view-unfold2.html template
91 # define 'unfold2_main' to the template engine
92 template_env [ 'unfold1_main' ] = main_plugin.render(request)
94 # more general variables expected in the template
95 template_env [ 'title' ] = 'Test view for hazelnut'
96 # the menu items on the top
97 template_env [ 'topmenu_items' ] = topmenu_items('slice', request)
98 # so we can sho who is logged
99 template_env [ 'username' ] = the_user (request)
101 ### # ########## add another plugin with the same request, on the RHS pane
102 ### # will show up in the right-hand side area named 'related'
103 ### related_plugin = SliceList (
105 ### title='Same request, other layout',
106 ### domid='sidelist',
107 ### with_datatables=True,
108 ### header='paginated main',
109 ### # share the query
110 ### query=main_query,
112 ### # likewise but on the side view
113 ### template_env [ 'unfold2_margin' ] = related_plugin.render (request)
115 ### # add our own css in the mix
116 ### page.add_css_files ( 'css/hazelnut.css')
118 # don't forget to run the requests
119 page.exec_queue_asynchroneously ()
121 # xxx create another plugin with the same query and a different layout (with_datatables)
122 # show that it worls as expected, one single api call to backend and 2 refreshed views
124 # the prelude object in page contains a summary of the requirements() for all plugins
125 # define {js,css}_{files,chunks}
126 prelude_env = page.prelude_env()
127 template_env.update(prelude_env)
128 result=render_to_response ('view-unfold1.html',template_env,
129 context_instance=RequestContext(request))
130 print 'result=',result