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 unfold.page import Page
12 from plugins.verticallayout.verticallayout import VerticalLayout
13 from plugins.tabs.tabs import Tabs
14 from plugins.lists.staticlist import StaticList
15 from plugins.quickfilter.quickfilter import QuickFilter
16 from plugins.raw.raw import Raw
18 from myslice.viewutils import topmenu_items, the_user
19 from myslice.viewutils import hard_wired_slice_names, hard_wired_list, lorem_p, lorem, quickfilter_criterias
22 def test_plugin_view (request):
26 # variables that will get passed to this template
30 VerticalLayout ( page=page,
31 title='title for the vertical layout',
32 sons = [ StaticList (page=page,
33 title='StaticList - with datatables - starts toggled off',
35 header='Hard wired header',
36 foo='the value for foo',
41 # *** we select this one to be the active tab ***
43 sons = [ Raw (page=page,
44 title='a raw plugin',domid='raw1',
50 header="static list but not togglable",
51 list=hard_wired_slice_names),
53 title='raw title',domid='raw2',
54 togglable=False,html=lorem) ]),
55 StaticList (page=page,
56 title='SimpleList with slice names',
57 list=hard_wired_slice_names,
59 QuickFilter (page=page,
60 title='QuickFilter in main content',
61 criterias=quickfilter_criterias,
63 # define 'content_main' to the template engine
64 template_env [ 'content_main' ] = main_plugin.render(request)
67 related_plugin = StaticList (page=page,
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 # we don't have anythong asynchroneous, but that doesn't hurt...
81 page.exec_queue_asynchroneously ()
83 # the prelude object in page contains a summary of the requirements() for all plugins
84 # define {js,css}_{files,chunks}
85 prelude_env = page.prelude_env()
86 template_env.update(prelude_env)
87 return render_to_response ('view-plugin.html',template_env,
88 context_instance=RequestContext(request))