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
11 from manifold.manifoldquery import ManifoldQuery
13 from plugins.stack.stack import Stack
14 from plugins.lists.slicelist import SliceList
15 from plugins.querycode.querycode import QueryCode
16 from plugins.quickfilter.quickfilter import QuickFilter
18 from myslice.viewutils import quickfilter_criterias
21 from myslice.viewutils import topmenu_items, the_user
24 def dashboard_view (request):
28 slices_query = ManifoldQuery (action='get',
32 # xxx filter : should filter on the slices the logged user can see
33 # we don't have the user's hrn yet
34 # in addition this currently returns all slices anyways
37 page.enqueue_query (slices_query)
41 title="Putting stuff together",
45 title="Vizualize your query (no syntax highlight for now)",
50 # we play with this one for demo purposes in dashboard.css
51 domid='myquickfilter',
53 title='play with filters',
54 criterias=quickfilter_criterias,
57 SliceList ( # setting visible attributes first
59 title='Asynchroneous SliceList',
61 with_datatables=False,
62 # this is the query at the core of the slice list
67 # variables that will get passed to the view-plugin.html template
70 # define 'unfold1_main' to the template engine
71 template_env [ 'unfold1_main' ] = main_plugin.render(request)
73 # more general variables expected in the template
74 template_env [ 'title' ] = 'Test view for a full request cycle'
75 # the menu items on the top
76 template_env [ 'topmenu_items' ] = topmenu_items('dashboard', request)
77 # so we can sho who is logged
78 template_env [ 'username' ] = the_user (request)
80 # ########## add another plugin with the same request, on the RHS pane
81 # will show up in the right-hand side area named 'related'
82 related_plugin = SliceList (
84 title='Same request, other layout',
87 header='paginated slices',
91 # likewise but on the side view
92 template_env [ 'unfold1_margin' ] = related_plugin.render (request)
94 # add our own css in the mix
95 page.add_css_files ( 'css/dashboard.css')
97 # don't forget to run the requests
98 page.exec_queue_asynchroneously ()
100 # xxx create another plugin with the same query and a different layout (with_datatables)
101 # show that it worls as expected, one single api call to backend and 2 refreshed views
103 # the prelude object in page contains a summary of the requirements() for all plugins
104 # define {js,css}_{files,chunks}
105 prelude_env = page.prelude_env()
106 template_env.update(prelude_env)
107 return render_to_response ('view-plugin.html',template_env,
108 context_instance=RequestContext(request))