clean the main layout now known as unfold1, including for the 2 pieces (unfold1_main...
[unfold.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
12 from plugins.stack.stack import Stack
13 from plugins.tabs.tabs import Tabs
14 from plugins.lists.staticlist import StaticList
15 from plugins.quickfilter.quickfilter import QuickFilter
16 from plugins.raw.raw import Raw
17
18 from myslice.viewutils import topmenu_items, the_user
19 from myslice.viewutils import hard_wired_slice_names, hard_wired_list, lorem_p, lorem, quickfilter_criterias
20
21 @login_required
22 def test_plugin_view (request):
23
24     page = Page(request)
25     
26     # variables that will get passed to this template
27     template_env = {}
28     
29     main_plugin = \
30         Stack ( page=page,
31                 title='title for the vertical layout',
32                 sons = [ StaticList (page=page,
33                                      title='StaticList - with datatables - starts toggled off',
34                                      list=hard_wired_list, 
35                                      header='Hard wired header', 
36                                      foo='the value for foo',
37                                      with_datatables=True,
38                                      toggled=False),
39                          Tabs (page=page,
40                                title='Sample Tabs',
41                                # *** we select this one to be the active tab ***
42                                active='raw2',
43                                sons = [ Raw (page=page,
44                                              title='a raw plugin',domid='raw1',
45                                              togglable=False,
46                                              html= 3*lorem_p),
47                                         StaticList(page=page,
48                                                    title='a slice list',
49                                                    togglable=False,
50                                                    header="static list but not togglable",
51                                                    list=hard_wired_slice_names),
52                                         Raw (page=page,
53                                              title='raw title',domid='raw2',
54                                              togglable=False,html=lorem) ]),
55                          StaticList (page=page,
56                                      title='SimpleList with slice names', 
57                                      list=hard_wired_slice_names,
58                                      ),
59                          QuickFilter (page=page,
60                                       title='QuickFilter in main content',
61                                       criterias=quickfilter_criterias,
62                                       ) ] )
63     # define 'unfold1_main' to the template engine
64     template_env [ 'unfold1_main' ] = main_plugin.render(request)
65
66     ##########
67     related_plugin = StaticList (page=page,
68                                  title='SliceList plugin',domid='slicelist1',
69                                  with_datatables='yes', 
70                                  list=hard_wired_slice_names, 
71                                  header='Slices')
72     # likewise but on the side view
73     template_env [ 'unfold1_margin' ] = related_plugin.render (request)
74
75     # more general variables expected in the template
76     template_env [ 'title' ] = 'Test Plugin View' 
77     template_env [ 'topmenu_items' ] = topmenu_items('plugin', request) 
78     template_env [ 'username' ] = the_user (request) 
79
80     # we don't have anythong asynchroneous, but that doesn't hurt...
81     page.exec_queue_asynchroneously ()
82
83     # the prelude object in page contains a summary of the requirements() for all plugins
84     # define {js,css}_{files,chunks}
85     prelude_env = page.prelude_env()
86     template_env.update(prelude_env)
87     return render_to_response ('view-plugin.html',template_env,
88                                context_instance=RequestContext(request))
89