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