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.googlemap.googlemap import GoogleMap
15 from plugins.senslabmap.senslabmap import SensLabMap
16 from plugins.lists.slicelist import SliceList
17 from plugins.querycode.querycode import QueryCode
18 from plugins.quickfilter.quickfilter import QuickFilter
20 from myslice.viewutils import quickfilter_criterias
22 from myslice.viewutils import topmenu_items, the_user
24 tmp_default_slice='ple.inria.sfatest'
27 def slice_view (request, slicename=tmp_default_slice):
31 main_query = ManifoldQuery (action='get',
34 fields=['network','type','hrn','hostname'],
35 filters= [ [ 'slice_hrn', '=', slicename, ] ],
37 page.enqueue_query (main_query)
41 title="Slice view for %s"%slicename,
46 title="2 tabs : w/ and w/o checkboxes",
48 # active_domid='checkboxes',
53 title='a sample and simple hazelnut',
55 # tab's sons preferably turn this off
57 # this is the query at the core of the slice list
62 title='with checkboxes',
64 # tab's sons preferably turn this off
66 # this is the query at the core of the slice list
69 datatables_options = {
70 # for now we turn off sorting on the checkboxes columns this way
71 # this of course should be automatic in hazelnut
72 'aoColumns' : [ None, None, None, None, {'bSortable': False} ],
73 'iDisplayLength' : 25,
74 'bLengthChange' : True,
79 title='geographic view',
81 # tab's sons preferably turn this off
89 # tab's sons preferably turn this off
98 # this is the query at the core of the slice list
100 columns=['hrn','hostname'],
102 # you don't *have to* set a domid, but if you plan on using toggled=persistent then it's required
103 # because domid is the key for storing toggle status in the browser
106 title='xmlrpc code (toggled=False)',
113 title="QuickFilter - requires metadata (toggled=False)",
114 criterias=quickfilter_criterias,
120 # variables that will get passed to the view-unfold1.html template
123 # define 'unfold1_main' to the template engine - the main contents
124 template_env [ 'unfold1_main' ] = main_plugin.render(request)
126 # more general variables expected in the template
127 template_env [ 'title' ] = 'Test view for hazelnut'
128 # the menu items on the top
129 template_env [ 'topmenu_items' ] = topmenu_items('slice', request)
130 # so we can sho who is logged
131 template_env [ 'username' ] = the_user (request)
133 # don't forget to run the requests
134 page.exec_queue_asynchroneously ()
136 # xxx create another plugin with the same query and a different layout (with_datatables)
137 # show that it worls as expected, one single api call to backend and 2 refreshed views
139 # the prelude object in page contains a summary of the requirements() for all plugins
140 # define {js,css}_{files,chunks}
141 prelude_env = page.prelude_env()
142 template_env.update(prelude_env)
143 result=render_to_response ('view-unfold1.html',template_env,
144 context_instance=RequestContext(request))