+from django.template import RequestContext
+from django.shortcuts import render_to_response
+
from manifold.core.query import Query
from unfold.page import Page
+from plugins.raw import Raw
+from plugins.stack import Stack
+from plugins.tabs import Tabs
+from plugins.googlemap import GoogleMap
+from plugins.senslabmap import SensLabMap
from unfold.loginrequired import FreeAccessView
from ui.topmenu import topmenu_items_live, the_user
from plugins.querytable import QueryTable
+from myslice.config import Config
+
# View for 1 platform and its details
class PlatformView(FreeAccessView):
template_name = "platform.html"
def get_context_data(self, **kwargs):
page = Page(self.request)
page.add_js_files ( [ "js/common.functions.js" ] )
+
for key, value in kwargs.iteritems():
print "%s = %s" % (key, value)
if key == "platformname":
.select('platform','platform_longname','gateway_type')
page.enqueue_query(network_query)
+ # ListResources of the platform
+ metadata = page.get_metadata()
+ resource_md = metadata.details_by_object('resource')
+ resource_fields = [column['name'] for column in resource_md['column']]
+ resources = platformname + ':resource'
+ query_resource_all = Query.get(resources).select(resource_fields)
+ page.enqueue_query(query_resource_all)
+ query_resource_default_fields = Query.get(resources).select('hrn','hostname', 'type','country')
+ page.enqueue_query(query_resource_default_fields)
+
page.expose_js_metadata()
networklist = QueryTable(
page = page,
'bLengthChange' : True,
},
)
-#
+
# networklist = SimpleList(
# title = None,
# page = page,
# key = 'platform',
# query = network_query,
# )
+#
+ # --------------------------------------------------------------------------
+ # RESOURCES
+ # for internal use in the querytable plugin;
+ # needs to be a unique column present for each returned record
+ main_query_init_key = 'hrn'
+
+ # the resources part is made of a Tabs (Geographic, List),
+ resources_as_gmap = GoogleMap(
+ page = page,
+ title = 'Geographic view',
+ domid = 'resources-map',
+ # tab's sons preferably turn this off
+ togglable = False,
+ query = query_resource_default_fields,
+ query_all = query_resource_all,
+ # this key is the one issued by google
+ googlemap_api_key = Config().googlemap_api_key(),
+ # the key to use at init-time
+ init_key = main_query_init_key,
+ checkboxes = False,
+ # center on Paris
+ latitude = 49.,
+ longitude = 9,
+ zoom = 4,
+ )
+ resources_as_3dmap = SensLabMap(
+ page = page,
+ title = '3D Map',
+ domid = 'senslabmap',
+ query = query_resource_default_fields,
+ query_all = query_resource_all,
+ )
+ resources_as_list = QueryTable(
+ page = page,
+ domid = 'resources-list',
+ title = 'List view',
+ # this is the query at the core of the slice list
+ query = query_resource_default_fields,
+ query_all = query_resource_all,
+ init_key = main_query_init_key,
+ checkboxes = False,
+ datatables_options = {
+ 'iDisplayLength': 25,
+ 'bLengthChange' : True,
+ 'bAutoWidth' : True,
+ },
+ )
+ resources_sons = [
+ resources_as_gmap,
+ resources_as_3dmap,
+ resources_as_list,
+ ]
+ resources_area = Tabs ( page=page,
+ domid="resources",
+ togglable=True,
+ title="Resources",
+ outline_complete=True,
+ sons= resources_sons,
+ active_domid = 'resources-map',
+ persistent_active=True,
+ )
context = super(PlatformView, self).get_context_data(**kwargs)
context['person'] = self.request.user
context['networks'] = networklist.render(self.request)
+ context['resources'] = resources_area.render(self.request)
# XXX This is repeated in all pages
# more general variables expected in the template
print 'credential_authorities =', credential_authorities
print 'credential_authorities_expired =', credential_authorities_expired
+ # Using cache manifold-tables to get the list of authorities faster
+ all_authorities_query = Query.get('authority').select('name', 'authority_hrn')
+ all_authorities = execute_query(self.request, all_authorities_query)
+
# ** Where am I a PI **
# For this we need to ask SFA (of all authorities) = PI function
pi_authorities_query = Query.get('user').filter_by('user_hrn', '==', '$user_hrn').select('pi_authorities')
for pa in pi_authorities_tmp:
pi_authorities |= set(pa['pi_authorities'])
+# include all sub-authorities of the PI
+# if PI on ple, include all sub-auths ple.upmc, ple.inria and so on...
+# a = set()
+# for authority in authorities:
+# for my_authority in my_authorities:
+# if authority.startswith(my_authority) and authority not in a:
+# a.add(authority)
+
+
+
print "pi_authorities =", pi_authorities
# My authorities + I have a credential