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, the_user
7 from plugins.googlemap import GoogleMap
8 from plugins.querytable import QueryTable
9 from plugins.lists.simplelist import SimpleList
10 from plugins.slicestat import SliceStat
12 # View for 1 platform and its details
13 class ResourceView(FreeAccessView):
14 template_name = "resource.html"
16 def get_context_data(self, **kwargs):
17 page = Page(self.request)
19 page.add_js_files ( [ "js/common.functions.js" ] )
21 for key, value in kwargs.iteritems():
22 print "%s = %s" % (key, value)
26 resource_query = Query().get('resource')\
27 .filter_by('urn', '==', resource_urn)\
28 .select('hostname','type','hrn','urn', 'latitude', 'longitude', 'country')
29 page.enqueue_query(resource_query)
31 page.expose_js_metadata()
34 resourcelist = QueryTable(
38 # this is the query at the core of the slice list
39 query = resource_query,
40 query_all = resource_query,
42 datatables_options = {
43 'iDisplayLength' : 25,
44 'bLengthChange' : True,
47 resource_as_map = GoogleMap(
49 title = 'Geographic view',
50 domid = 'resources-map',
51 # tab's sons preferably turn this off
53 query = resource_query,
54 query_all = resource_query,
61 # resourcelist = SimpleList(
65 # query = resource_query,
68 resource_stats = SliceStat(
73 query = resource_query
76 context = super(ResourceView, self).get_context_data(**kwargs)
77 context['person'] = self.request.user
78 context['resource'] = resourcelist.render(self.request)
79 context['resource_as_map'] = resource_as_map.render(self.request)
80 context['resource_stats'] = resource_stats.render(self.request)
82 # XXX This is repeated in all pages
83 # more general variables expected in the template
84 context['title'] = 'Information about a resource'
85 # the menu items on the top
86 context['topmenu_items'] = topmenu_items(None, self.request)
87 # so we can sho who is logged
88 context['username'] = the_user(self.request)
90 context.update(page.prelude_env())