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.hazelnut.hazelnut import Hazelnut
13 from plugins.lists.slicelist import SliceList
14 from plugins.querycode.querycode import QueryCode
15 from plugins.quickfilter.quickfilter import QuickFilter
17 from myslice.viewutils import quickfilter_criterias
19 from myslice.viewutils import topmenu_items, the_user
22 def hazelnut_view (request):
26 main_query = ManifoldQuery (action='get',
29 fields=['hrn','hostname'],
30 filters= [ [ 'slice_hrn', '=', 'ple.inria.', ] ],
31 # xxx filter : should filter on the slices the logged user can see
32 # we don't have the user's hrn yet
33 # in addition this currently returns all slices anyways
37 page.enqueue_query (main_query)
41 title="global container",
43 Hazelnut ( # setting visible attributes first
45 title='a sample and simple hazelnut',
46 # this is the query at the core of the slice list
51 # variables that will get passed to the view-plugin.html template
54 # define 'unfold1_main' to the template engine
55 template_env [ 'unfold1_main' ] = main_plugin.render(request)
57 # more general variables expected in the template
58 template_env [ 'title' ] = 'Test view for hazelnut'
59 # the menu items on the top
60 template_env [ 'topmenu_items' ] = topmenu_items('hazelnut', request)
61 # so we can sho who is logged
62 template_env [ 'username' ] = the_user (request)
64 # ########## add another plugin with the same request, on the RHS pane
65 # will show up in the right-hand side area named 'related'
66 related_plugin = SliceList (
68 title='Same request, other layout',
71 header='paginated main',
75 # likewise but on the side view
76 template_env [ 'unfold1_margin' ] = related_plugin.render (request)
78 # add our own css in the mix
79 page.add_css_files ( 'css/hazelnut.css')
81 # don't forget to run the requests
82 page.exec_queue_asynchroneously ()
84 # xxx create another plugin with the same query and a different layout (with_datatables)
85 # show that it worls as expected, one single api call to backend and 2 refreshed views
87 # the prelude object in page contains a summary of the requirements() for all plugins
88 # define {js,css}_{files,chunks}
89 prelude_env = page.prelude_env()
90 template_env.update(prelude_env)
91 return render_to_response ('view-plugin.html',template_env,
92 context_instance=RequestContext(request))