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