rename render_env -> template_env
[myslice.git] / engine / views.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 plugins.verticallayout import VerticalLayout
9 from plugins.tabs import Tabs
10 from plugins.simplelist import SimpleList
11 from plugins.slicelist import SliceList
12 from plugins.raw import Raw
13
14 from myslice.viewutils import topmenu_items, the_user
15 from myslice.viewutils import hard_wired_slice_names, hard_wired_list, lorem_p, lorem
16
17 def test_plugin_view (request):
18     
19     # variables that will get passed to this template
20     template_env = {}
21     
22     main_plugin = \
23         VerticalLayout ( sons = [ SimpleList (list=hard_wired_list, 
24                                               header='Hard wired', 
25                                               foo='the value for foo',
26                                               with_datatables=True),
27                                   Tabs (sons = [ Raw (html= 3*lorem_p),
28                                                  SliceList(list=hard_wired_slice_names),
29                                                  Raw (html=lorem) ]),
30                                   SimpleList (list=hard_wired_slice_names,
31                                               headers='Slices in main content') ] )
32     # define 'content_main' to the template engine
33     template_env [ 'content_main' ] = main_plugin.render(request)
34
35     ##########
36     # lacks a/href to /slice/%s
37     related_plugin = SliceList (visible=True, 
38                                 hidable=True,
39                                 with_datatables='yes', 
40                                 list=hard_wired_slice_names, 
41                                 header='Slices' )
42     # likewise but on the side view
43     template_env [ 'content_related' ] = related_plugin.render (request)
44
45     # more general variables expected in the template
46     template_env [ 'title' ] = 'Test Plugin View' 
47     template_env [ 'topmenu_items' ] = topmenu_items('plugin', request) 
48     template_env [ 'username' ] = the_user (request) 
49
50     # request.plugin_prelude holds a summary of the requirements() for all plugins
51     # define {js,css}_{files,chunks}
52     prelude_env = request.plugin_prelude.template_env()
53     print 'prelude_env',prelude_env
54     template_env.update(prelude_env)
55
56     return render_to_response ('view-plugin.html',template_env,
57                                context_instance=RequestContext(request))
58