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=['network','type','hrn','hostname'],
33 filters= [ [ 'slice_hrn', '=', slicename, ] ],
35 page.enqueue_query (main_query)
39 title="Slice view for %s"%slicename,
44 title="2 tabs : w/ and w/o checkboxes",
47 active_domid='checkboxes',
51 title='a sample and simple hazelnut',
54 # this is the query at the core of the slice list
59 title='with checkboxes',
63 # this is the query at the core of the slice list
65 # this of course should be automatic in hazelnut
66 # for now we turn off sorting on the checkboxes columns this way
67 datatables_options = { 'aoColumns' : [ None, None, None, None, {'bSortable': False} ] },
75 # this is the query at the core of the slice list
77 columns=['hrn','hostname'],
87 title="QuickFilter is currently the only one that requires metadata",
88 criterias=quickfilter_criterias
92 # variables that will get passed to the view-unfold1.html template
95 # define 'unfold1_main' to the template engine - the main contents
96 template_env [ 'unfold1_main' ] = main_plugin.render(request)
98 # more general variables expected in the template
99 template_env [ 'title' ] = 'Test view for hazelnut'
100 # the menu items on the top
101 template_env [ 'topmenu_items' ] = topmenu_items('slice', request)
102 # so we can sho who is logged
103 template_env [ 'username' ] = the_user (request)
105 # don't forget to run the requests
106 page.exec_queue_asynchroneously ()
108 # xxx create another plugin with the same query and a different layout (with_datatables)
109 # show that it worls as expected, one single api call to backend and 2 refreshed views
111 # the prelude object in page contains a summary of the requirements() for all plugins
112 # define {js,css}_{files,chunks}
113 prelude_env = page.prelude_env()
114 template_env.update(prelude_env)
115 result=render_to_response ('view-unfold1.html',template_env,
116 context_instance=RequestContext(request))