verticallayout as an elementary building plugin
[unfold.git] / engine / views.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 plugins.verticallayout import VerticalLayout
9 from plugins.simplelist import SimpleList
10
11 from myslice.viewutils import topmenu_items, the_user, hard_wired_slice_names
12
13 def test_plugin_view (request):
14     
15     # having html tags right here is not a real use case
16     hard_wired_list=[]
17     hard_wired_list.append("this hard-wired list")
18     hard_wired_list.append("is defined")
19     hard_wired_list.append("in plugins.simplelist.py")
20     hard_wired_list.append("which in turn relies on")
21     hard_wired_list.append("template widget-template.html")
22     hard_wired_list.append("while it should of course")
23     hard_wired_list.append("instead issue a query")
24     hard_wired_list.append("and fill the DOM in js from there")
25     hard_wired_list.append("it would however maybe make sense")
26     hard_wired_list.append("to offer the option to 'datatablify'")
27     hard_wired_list.append("the list from the python code")
28     hard_wired_list.append("just like a standard plugin can be set as visible or not")
29     hard_wired_list.append("")    
30     hard_wired_list.append("OTOH and IMHO, there should be two separate and explicit subclasses of SimpleList for slices or testbeds")
31
32     plugin_main1 = SimpleList (list=hard_wired_list, 
33                                header='Hard wired', 
34                                foo='the value for foo')
35     plugin_main2 = SimpleList (hidable=True, 
36                                list=hard_wired_slice_names,
37                                headers='Slices in main content')
38     layout = VerticalLayout (hidable=True, visible=True,
39                              sons=[plugin_main1, plugin_main2]
40                              )
41     content_main = layout.render (request)
42
43     # lacks a/href to /slice/%s
44     plugin_related = SimpleList (visible=True, hidable=True,
45                                  need_datatables='yes', 
46                                  list=hard_wired_slice_names, 
47                                  header='Slices' )
48     content_related = plugin_related.render (request)
49
50     
51
52     return render_to_response ('view-plugin.html',
53                                {'title': 'Test Plugin View',
54                                 'topmenu_items': topmenu_items('plugin', request),
55                                 'content_main' : content_main,
56                                 'content_related' : content_related,
57                                 'username' : the_user (request),
58                                 },
59                                context_instance=RequestContext(request))
60