142d33b49d3da7ba5a2a7dc8b818c2217b28cbc9
[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.manifoldquery import ManifoldQuery
11
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
18
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
21
22 @login_required
23 def dashboard_view (request):
24     
25     slices_query = ManifoldQuery (action='get',
26                                   method='slice',
27                                   timestamp='latest',
28                                   fields=['slice_hrn'],
29                                   # xxx filter : should filter on the slices the logged user can see
30                                   # we don't have the user's hrn yet
31                                   # in addition this currently returns all slices anyways
32                                   sort='slice_hrn',)
33
34     # variables that will get passed to this template
35     template_env = {}
36     
37     main_plugin = SimpleList ( # setting visible attributes first
38         title='SimpleList and dataTables',
39         header='slices list', 
40         with_datatables=True,
41         toggled=False,
42         # this is required for the javascript code
43         query=slices_query,
44         key='slice_hrn',
45         value='slice_hrn',
46 )
47
48     # define 'content_main' to the template engine
49     template_env [ 'content_main' ] = main_plugin.render(request)
50
51 #    ##########
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' ] = 'Test Plugin View' 
62     template_env [ 'topmenu_items' ] = topmenu_items('dashboard', request) 
63     template_env [ 'username' ] = the_user (request) 
64
65     # request.plugin_prelude holds a summary of the requirements() for all plugins
66     # define {js,css}_{files,chunks}
67     prelude_env = request.plugin_prelude.template_env()
68     template_env.update(prelude_env)
69
70     return render_to_response ('view-plugin.html',template_env,
71                                context_instance=RequestContext(request))
72