redrawing slice view
[myslice.git] / trash / pluginview.py
1 # Create your views here.
2
3 from django.core.context_processors     import csrf
4 from django.template                    import RequestContext
5 from django.template.loader             import render_to_string
6 from django.shortcuts                   import render_to_response
7
8 from django.contrib.auth.decorators     import login_required
9
10 from unfold.page                        import Page
11 from manifold.core.query                import Query
12
13 from plugins.stack.stack                import Stack
14 from plugins.tabs.tabs                  import Tabs
15 from plugins.lists.staticlist           import StaticList
16 from plugins.quickfilter.quickfilter    import QuickFilter
17 from plugins.querycode.querycode        import QueryCode
18 from plugins.raw.raw                    import Raw
19 from plugins.messages.messages          import Messages
20 from plugins.hazelnut                   import Hazelnut
21 from plugins.updater                    import Updater
22
23 from myslice.viewutils                  import topmenu_items, the_user
24 from trash.trashutils                  import hard_wired_slice_names, hard_wired_list, lorem_p, lorem, quickfilter_criterias
25
26 @login_required
27 def test_plugin_view (request):
28
29     page = Page(request)
30     
31     # variables that will get passed to this template
32     template_env = {}
33     
34     slicename='ple.inria.heartbeat'
35     main_query = Query.get('resource').filter_by('slice_hrn', '=', slicename).select(['network','type','hrn','hostname','sliver'])
36     # without an hazelnut, this would use use : run_it=False as nothing would listen to the results
37     page.enqueue_query (main_query, # run_it=False
38                         )
39
40     main_plugin = \
41         Stack (
42         page=page,
43         title='thestack',
44         togglable=True,
45         domid='stack',
46         sons=[ \
47 # this updater thing never made it to production                
48 #            Updater (
49 #                    page=page,
50 #                    title="Won't show up as non togglable",
51 #                    query=main_query,
52 #                    label="Update me",
53 #                    domid="the-updater",
54 #                ),
55         # make sure the 2 things work together
56             Hazelnut (
57                     page=page,
58                     title="Slice %s - checkboxes interacting w/ updater"%slicename,
59                     query=main_query,
60                     domid="hazelnut",
61                     checkboxes=True,
62                     togglable=True,
63                     ),
64             Messages (
65                     page=page,
66                     title="Runtime messages",
67                     domid="messages",
68                     levels='ALL',
69                     togglable=True,
70                     ),
71             ])
72
73     # define 'unfold1_main' to the template engine
74     template_env [ 'unfold1_main' ] = main_plugin.render(request)
75
76     # more general variables expected in the template
77     template_env [ 'title' ] = 'Single Plugin View' 
78     template_env [ 'topmenu_items' ] = topmenu_items('plugin', request) 
79     template_env [ 'username' ] = the_user (request) 
80
81     # run queries when we have any
82     page.expose_queries ()
83
84     # the prelude object in page contains a summary of the requirements() for all plugins
85     # define {js,css}_{files,chunks}
86     prelude_env = page.prelude_env()
87     template_env.update(prelude_env)
88     return render_to_response ('view-unfold1.html',template_env,
89                                context_instance=RequestContext(request))
90