1 from manifold.core.query import Query
2 from unfold.page import Page
4 from unfold.loginrequired import FreeAccessView
5 from ui.topmenu import topmenu_items_live, the_user
7 from plugins.querytable import QueryTable
8 from myslice.theme import ThemeView
11 class PlatformsView(FreeAccessView, ThemeView):
12 template_name = "platforms.html"
14 def get_context_data(self, **kwargs):
15 page = Page(self.request)
16 page.add_js_files ( [ "js/common.functions.js" ] )
17 platform_query = Query().get('local:platform').filter_by('disabled', '==', '0').select('platform','platform_longname','gateway_type')
18 #platform_query = Query().get('local:platform').select('platform','platform_longname','gateway_type')
19 page.enqueue_query(platform_query)
21 page.expose_js_metadata()
22 platformlist = QueryTable(
26 # this is the query at the core of the slice list
27 query = platform_query,
28 query_all = platform_query,
30 init_key = 'platform',
31 datatables_options = {
33 'bLengthChange' : True,
38 context = super(PlatformsView, self).get_context_data(**kwargs)
39 context['person'] = self.request.user
40 context['platforms'] = platformlist.render(self.request)
42 # XXX This is repeated in all pages
43 # more general variables expected in the template
44 context['title'] = 'Platforms connected to MySlice'
45 # the menu items on the top
46 context['topmenu_items'] = topmenu_items_live('Platforms', page)
47 # so we can sho who is logged
48 context['username'] = the_user(self.request)
49 context['theme'] = self.theme
50 context.update(page.prelude_env())
52 context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html"