Merge branch 'master' of ssh://git.onelab.eu/git/myslice-django
[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.manifoldquery import ManifoldQuery
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.raw.raw import Raw
18 from plugins.messages.messages import Messages
19 from plugins.updater.updater import Updater
20
21 from myslice.viewutils import topmenu_items, the_user
22 from myslice.viewutils import hard_wired_slice_names, hard_wired_list, lorem_p, lorem, quickfilter_criterias
23
24 @login_required
25 def test_plugin_view (request):
26
27     page = Page(request)
28     
29     # variables that will get passed to this template
30     template_env = {}
31     
32     slicename='ple.inria.omftest'
33     main_query = ManifoldQuery (action='get',
34                                 subject='resource',
35                                 timestamp='latest',
36                                 fields=['network','type','hrn','hostname'],
37                                 filters= [ [ 'slice_hrn', '=', slicename, ] ],
38                                 )
39
40     main_plugin = \
41         Stack (
42         page=page,
43         title='thestack',
44         togglable=False,
45         sons=[ \
46             Messages (
47                 page=page,
48                 title="Runtime messages",
49                 domid="msgs-pre",
50                 ),
51             Updater (
52                     page=page,
53                     title="Update me",
54                     query=main_query,
55                     label="Update me",
56                     ),
57             ])
58
59     # define 'unfold1_main' to the template engine
60     template_env [ 'unfold1_main' ] = main_plugin.render(request)
61
62     # more general variables expected in the template
63     template_env [ 'title' ] = 'Single Plugin View' 
64     template_env [ 'topmenu_items' ] = topmenu_items('plugin', request) 
65     template_env [ 'username' ] = the_user (request) 
66
67     # we don't have anythong asynchroneous, and manifold.js is not loaded
68 #    page.exec_queue_asynchroneously ()
69
70     # the prelude object in page contains a summary of the requirements() for all plugins
71     # define {js,css}_{files,chunks}
72     prelude_env = page.prelude_env()
73     template_env.update(prelude_env)
74     return render_to_response ('view-unfold1.html',template_env,
75                                context_instance=RequestContext(request))
76