new object pluginset
[myslice.git] / myslice / dashboard.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 django.contrib.auth.decorators import login_required
9
10 from engine.pluginset import PluginSet
11 from engine.manifoldquery import ManifoldQuery
12
13 from plugins.simplelist import SimpleList
14
15
16 from myslice.viewutils import topmenu_items, the_user
17 # from myslice.viewutils import hard_wired_slice_names, hard_wired_list, lorem_p, lorem, quickfilter_criterias
18
19 @login_required
20 def dashboard_view (request):
21     
22     pluginset = PluginSet()
23
24     slices_query = ManifoldQuery (action='get',
25                                   method='slice',
26                                   timestamp='latest',
27                                   fields=['slice_hrn'],
28                                   # xxx filter : should filter on the slices the logged user can see
29                                   # we don't have the user's hrn yet
30                                   # in addition this currently returns all slices anyways
31                                   sort='slice_hrn',)
32
33     main_plugin = SimpleList ( # setting visible attributes first
34         pluginset=pluginset,
35         title='SimpleList and dataTables',
36         header='slices list', 
37         with_datatables=True,
38         toggled=False,
39         # this is required for the javascript code
40         query=slices_query,
41         key='slice_hrn',
42         value='slice_hrn',
43         )
44
45     # variables that will get passed to the view-plugin.html template
46     template_env = {}
47     
48     # define 'content_main' to the template engine
49     template_env [ 'content_main' ] = main_plugin.render(request)
50
51 #    ########## add another plugin with the same request, on the RHS pane
52 #    # lacks a/href to /slice/%s
53 #    related_plugin = SliceList (title='SliceList plugin',domid='slicelist1',
54 #                                with_datatables='yes', 
55 #                                list=hard_wired_slice_names, 
56 #                                header='Slices')
57 #    # likewise but on the side view
58 #    template_env [ 'content_related' ] = related_plugin.render (request)
59
60     # more general variables expected in the template
61     template_env [ 'title' ] = 'SimpleList Test View'
62     # the menu items on the top 
63     template_env [ 'topmenu_items' ] = topmenu_items('dashboard', request) 
64     # so we can sho who is logged
65     template_env [ 'username' ] = the_user (request) 
66
67     pluginset.exec_queue_asynchroneously ()
68
69     # request.plugin_prelude holds a summary of the requirements() for all plugins
70     # define {js,css}_{files,chunks}
71     prelude_env = pluginset.template_env()
72     template_env.update(prelude_env)
73     return render_to_response ('view-plugin.html',template_env,
74                                context_instance=RequestContext(request))
75