load manifold api metadata ...
[unfold.git] / trash / 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(request)
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     pluginset.enqueue_query (slices_query)
33
34     main_plugin = SimpleList ( # setting visible attributes first
35         pluginset=pluginset,
36         title='Asynchroneous SimpleList',
37         header='slices list', 
38         with_datatables=True,
39         toggled=True,
40         # this is required for the javascript code
41         query=slices_query,
42         key='slice_hrn',
43         value='slice_hrn',
44         )
45
46     # variables that will get passed to the view-plugin.html template
47     template_env = {}
48     
49     # define 'content_main' to the template engine
50     template_env [ 'content_main' ] = main_plugin.render(request)
51
52 #    ########## add another plugin with the same request, on the RHS pane
53 #    # lacks a/href to /slice/%s
54 #    related_plugin = SliceList (title='SliceList plugin',domid='slicelist1',
55 #                                with_datatables='yes', 
56 #                                list=hard_wired_slice_names, 
57 #                                header='Slices')
58 #    # likewise but on the side view
59 #    template_env [ 'content_related' ] = related_plugin.render (request)
60
61     # more general variables expected in the template
62     template_env [ 'title' ] = 'Test view for a full request cycle'
63     # the menu items on the top 
64     template_env [ 'topmenu_items' ] = topmenu_items('dashboard', request) 
65     # so we can sho who is logged
66     template_env [ 'username' ] = the_user (request) 
67
68     pluginset.exec_queue_asynchroneously ()
69
70     # the prelude object in pluginset contains a summary of the requirements() for all plugins
71     # define {js,css}_{files,chunks}
72     prelude_env = pluginset.template_env()
73     template_env.update(prelude_env)
74     return render_to_response ('view-plugin.html',template_env,
75                                context_instance=RequestContext(request))