don't always set domid
[unfold.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 django.contrib.auth.decorators import login_required
9
10 from plugins.verticallayout import VerticalLayout
11 from plugins.tabs import Tabs
12 from plugins.simplelist import SimpleList
13 from plugins.slicelist import SliceList
14 from plugins.raw import Raw
15
16 from myslice.viewutils import topmenu_items, the_user
17 from myslice.viewutils import hard_wired_slice_names, hard_wired_list, lorem_p, lorem
18
19 @login_required
20 def test_plugin_view (request):
21     
22     # variables that will get passed to this template
23     template_env = {}
24     
25     main_plugin = \
26         VerticalLayout ( title='title for the vertical layout',
27         sons = [ SimpleList (title='SimpleList and dataTables',
28                              list=hard_wired_list, 
29                              header='Hard wired', 
30                              foo='the value for foo',
31                              with_datatables=True,
32                              toggled=False),
33                  Tabs (title='Sample Tabs',
34                        # *** we select this one to be the active tab ***
35                        active='raw2',
36                        sons = [ Raw (title='a raw plugin',domid='raw1',
37                                      togglable=False,
38                                      html= 3*lorem_p),
39                                 SliceList(title='a slice list',
40                                           togglable=False,
41                                           list=hard_wired_slice_names),
42                                 Raw (title='raw title',domid='raw2',
43                                      togglable=False,html=lorem) ]),
44                  SimpleList (title='SimpleList with slice names', 
45                              list=hard_wired_slice_names,
46                              ) ] )
47     # define 'content_main' to the template engine
48     template_env [ 'content_main' ] = main_plugin.render(request)
49
50     ##########
51     # lacks a/href to /slice/%s
52     related_plugin = SliceList (title='SliceList plugin',domid='slicelist1',
53                                 with_datatables='yes', 
54                                 list=hard_wired_slice_names, 
55                                 header='Slices')
56     # likewise but on the side view
57     template_env [ 'content_related' ] = related_plugin.render (request)
58
59     # more general variables expected in the template
60     template_env [ 'title' ] = 'Test Plugin View' 
61     template_env [ 'topmenu_items' ] = topmenu_items('plugin', request) 
62     template_env [ 'username' ] = the_user (request) 
63
64     # request.plugin_prelude holds a summary of the requirements() for all plugins
65     # define {js,css}_{files,chunks}
66     prelude_env = request.plugin_prelude.template_env()
67     template_env.update(prelude_env)
68
69     return render_to_response ('view-plugin.html',template_env,
70                                context_instance=RequestContext(request))
71