1 # Create your views here.
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
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
14 from myslice.viewutils import topmenu_items, the_user
15 from myslice.viewutils import hard_wired_slice_names, hard_wired_list, lorem_p, lorem
17 def test_plugin_view (request):
19 # variables that will get passed to this template
23 VerticalLayout ( sons = [ SimpleList (list=hard_wired_list,
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),
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)
36 # lacks a/href to /slice/%s
37 related_plugin = SliceList (visible=True,
39 with_datatables='yes',
40 list=hard_wired_slice_names,
42 # likewise but on the side view
43 template_env [ 'content_related' ] = related_plugin.render (request)
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)
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)
56 return render_to_response ('view-plugin.html',template_env,
57 context_instance=RequestContext(request))