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 django.contrib.auth.decorators import login_required
10 from engine.pluginset import PluginSet
12 from plugins.verticallayout import VerticalLayout
13 from plugins.tabs import Tabs
14 from plugins.simplelist import SimpleList
15 from plugins.slicelist import SliceList
16 from plugins.quickfilter import QuickFilter
17 from plugins.raw import Raw
19 from myslice.viewutils import topmenu_items, the_user
20 from myslice.viewutils import hard_wired_slice_names, hard_wired_list, lorem_p, lorem, quickfilter_criterias
23 def test_plugin_view (request):
25 pluginset = PluginSet()
27 # variables that will get passed to this template
31 VerticalLayout ( pluginset=pluginset,
32 title='title for the vertical layout',
33 sons = [ SimpleList (pluginset=pluginset,
34 title='SimpleList and dataTables',
37 foo='the value for foo',
40 Tabs (pluginset=pluginset,
42 # *** we select this one to be the active tab ***
44 sons = [ Raw (pluginset=pluginset,
45 title='a raw plugin',domid='raw1',
48 SliceList(pluginset=pluginset,
51 list=hard_wired_slice_names),
52 Raw (pluginset=pluginset,
53 title='raw title',domid='raw2',
54 togglable=False,html=lorem) ]),
55 SimpleList (pluginset=pluginset,
56 title='SimpleList with slice names',
57 list=hard_wired_slice_names,
59 QuickFilter (list=quickfilter_criterias,
61 title='QuickFilter in main content') ] )
62 # define 'content_main' to the template engine
63 template_env [ 'content_main' ] = main_plugin.render(request)
66 # lacks a/href to /slice/%s
67 related_plugin = SliceList (pluginset=pluginset,
68 title='SliceList plugin',domid='slicelist1',
69 with_datatables='yes',
70 list=hard_wired_slice_names,
72 # likewise but on the side view
73 template_env [ 'content_related' ] = related_plugin.render (request)
75 # more general variables expected in the template
76 template_env [ 'title' ] = 'Test Plugin View'
77 template_env [ 'topmenu_items' ] = topmenu_items('plugin', request)
78 template_env [ 'username' ] = the_user (request)
80 pluginset.exec_queue_asynchroneously ()
82 # the prelude object in pluginset contains a summary of the requirements() for all plugins
83 # define {js,css}_{files,chunks}
84 prelude_env = pluginset.template_env()
85 template_env.update(prelude_env)
86 return render_to_response ('view-plugin.html',template_env,
87 context_instance=RequestContext(request))