keep only import topmenu_items, the_user in myslice/viewutils
[myslice.git] / trash / sampleviews.py
1 # Create your views here.
2 from django.core.context_processors import csrf
3 from django.template import RequestContext
4 from django.shortcuts import render_to_response
5 from django.contrib.auth.decorators import login_required
6
7 from unfold.prelude import Prelude
8
9 from myslice.viewutils import topmenu_items, the_user
10 # tmp
11 from trash.trashutils  import lorem, hard_wired_slice_names
12
13 @login_required
14 def tab_view (request):
15     prelude=Prelude( js_files='js/bootstrap.js', css_files='css/bootstrap.css')
16     prelude_env = prelude.prelude_env()
17
18     tab_env = {'title':'Page for playing with Tabs',
19                'topmenu_items': topmenu_items('tab',request),
20                'username':the_user (request),
21                'lorem': lorem,                                
22                }
23     tab_env.update (prelude_env)
24     return render_to_response ('view-tab.html', tab_env,
25                                context_instance=RequestContext(request))
26
27 def scroll_view (request):
28     return render_to_response ('view-scroll.html',
29                                {'title':'Toy page for scrolling',
30                                 'topmenu_items': topmenu_items('scroll',request),
31                                 'username':the_user (request),
32                                 'lorem':lorem,
33                                 },
34                                context_instance=RequestContext(request))
35
36 @login_required
37 def test_plugin_view (request):
38
39     page = Page(request)
40     
41     # variables that will get passed to this template
42     template_env = {}
43     
44     main_plugin = \
45         Stack ( page=page,
46                 title='title for the vertical layout',
47                 sons = [ StaticList (page=page,
48                                      title='StaticList - with datatables - starts toggled off',
49                                      list=hard_wired_list, 
50                                      header='Hard wired header', 
51                                      foo='the value for foo',
52                                      with_datatables=True,
53                                      toggled=False),
54                          Tabs (page=page,
55                                title='Sample Tabs',
56                                domid='test-tabs',
57                                # *** we select this one to be the active tab ***
58                                active_domid='son2',
59                                sons = [ Raw (page=page,
60                                              title='a raw plugin',
61                                              domid='son0',
62                                              togglable=False,
63                                              html= 3*lorem_p,
64                                              ),
65                                         StaticList(page=page,
66                                                    title='a slice list',
67                                                    domid='son1',
68                                                    togglable=False,
69                                                    header="static list but not togglable",
70                                                    list=hard_wired_slice_names,
71                                                    ),
72                                         Raw (page=page,
73                                              title='raw title',
74                                              domid='son2',
75                                              togglable=False,
76                                              html=lorem) ]),
77                          StaticList (page=page,
78                                      title='SimpleList with slice names', 
79                                      list=hard_wired_slice_names,
80                                      ),
81                          QuickFilter (page=page,
82                                       title='QuickFilter in main content',
83                                       criterias=quickfilter_criterias,
84                                       ) ] )
85     # define 'unfold2_main' to the template engine
86     template_env [ 'unfold2_main' ] = main_plugin.render(request)
87
88     ##########
89     related_plugin = StaticList (page=page,
90                                  title='SliceList plugin',domid='slicelist1',
91                                  with_datatables='yes', 
92                                  list=hard_wired_slice_names, 
93                                  header='Slices')
94     # likewise but on the side view
95     template_env [ 'unfold2_margin' ] = related_plugin.render (request)
96
97     # more general variables expected in the template
98     template_env [ 'title' ] = 'Test Plugin View' 
99     template_env [ 'topmenu_items' ] = topmenu_items('plugin', request) 
100     template_env [ 'username' ] = the_user (request) 
101
102     # we don't have anythong asynchroneous, and manifold.js is not loaded
103 #    page.expose_queries ()
104
105     # the prelude object in page contains a summary of the requirements() for all plugins
106     # define {js,css}_{files,chunks}
107     prelude_env = page.prelude_env()
108     template_env.update(prelude_env)
109     return render_to_response ('view-unfold2.html',template_env,
110                                context_instance=RequestContext(request))
111