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.simplelist import SimpleList
10 from plugins.slicelist import SliceList
12 from myslice.viewutils import topmenu_items, the_user, hard_wired_slice_names
14 def test_plugin_view (request):
16 # variables that will get passed to this template
19 # having html tags right here is not a real use case
21 hard_wired_list.append("this hard-wired list")
22 hard_wired_list.append("is defined")
23 hard_wired_list.append("in plugins.simplelist.py")
24 hard_wired_list.append("which in turn relies on")
25 hard_wired_list.append("template widget-template.html")
26 hard_wired_list.append("while it should of course")
27 hard_wired_list.append("instead issue a query")
28 hard_wired_list.append("and fill the DOM in js from there")
29 hard_wired_list.append("it would however maybe make sense")
30 hard_wired_list.append("to offer the option to 'datatablify'")
31 hard_wired_list.append("the list from the python code")
32 hard_wired_list.append("just like a standard plugin can be set as visible or not")
33 hard_wired_list.append("")
34 hard_wired_list.append("OTOH and IMHO, there should be two separate and explicit subclasses of SimpleList for slices or testbeds")
36 plugin_main1 = SimpleList (list=hard_wired_list,
38 foo='the value for foo',
40 plugin_main2 = SimpleList (hidable=True,
41 list=hard_wired_slice_names,
42 headers='Slices in main content')
43 layout = VerticalLayout (hidable=True, visible=True,
44 sons=[plugin_main1, plugin_main2]
46 # layout.inspect_request (request,"before first render")
47 content_main = layout.render (request)
48 # layout.inspect_request (request,"after first render")
49 # this will be rendered as the main content - as per view-plugin.html and thus layout-myslice.html
50 template_env [ 'content_main' ] = content_main
53 # lacks a/href to /slice/%s
54 plugin_related = SliceList (visible=True,
56 with_datatables='yes',
57 list=hard_wired_slice_names,
59 content_related = plugin_related.render (request)
60 # likewise but on the side view
61 template_env [ 'content_related' ] = content_related
63 # more general variables expected in the template
64 template_env [ 'title' ] = 'Test Plugin View'
65 template_env [ 'topmenu_items' ] = topmenu_items('plugin', request)
66 template_env [ 'username' ] = the_user (request)
68 # request.plugin_prelude holds a summary of the requirements() for all plugins
69 # define {js,css}_{files,chunks}
70 prelude_env = request.plugin_prelude.render_env()
71 print 'prelude_env',prelude_env
72 template_env.update(prelude_env)
74 return render_to_response ('view-plugin.html',template_env,
75 context_instance=RequestContext(request))