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