From: Loic Baron Date: Fri, 7 Feb 2014 22:21:00 +0000 (+0100) Subject: Added resources to the platform description, fixed link in querytable for the init_ke... X-Git-Tag: myslice-0.3-0~5 X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=a52c3773de8611def256d97dd699ba09d390b8fd Added resources to the platform description, fixed link in querytable for the init_key of the object, black color for dataTable plugins, started validation list of all sub-auths (unfinished) --- diff --git a/manifold/manifoldproxy.py b/manifold/manifoldproxy.py index d43a3cd4..debd1f7a 100644 --- a/manifold/manifoldproxy.py +++ b/manifold/manifoldproxy.py @@ -55,6 +55,7 @@ with the query passed using POST""" admin_user, admin_password = Config().manifold_admin_user_password() manifold_api_session_auth = {'AuthMethod': 'password', 'Username': admin_user, 'AuthString': admin_password} else: + print request.session['manifold'] manifold_api_session_auth = request.session['manifold']['auth'] if debug_empty and manifold_query.action.lower()=='get': diff --git a/plugins/querytable/static/js/querytable.js b/plugins/querytable/static/js/querytable.js index 19ecd6cc..15ee6f1c 100644 --- a/plugins/querytable/static/js/querytable.js +++ b/plugins/querytable/static/js/querytable.js @@ -207,8 +207,20 @@ else line.push(record['hostname']); - } else if (colnames[j] == 'hrn' && typeof(record) != 'undefined') { - line.push(' '+record['hrn']); + } else if (colnames[j] == this.init_key && typeof(record) != 'undefined') { + obj = this.object + o = obj.split(':'); + if(o.length>1){ + obj = o[1]; + }else{ + obj = o[0]; + } + /* XXX TODO: Remove this and have something consistant */ + if(obj=='resource'){ + line.push(' '+record[this.init_key]); + }else{ + line.push(' '+record[this.init_key]); + } } else { if (record[colnames[j]]) line.push(record[colnames[j]]); diff --git a/portal/platformsview.py b/portal/platformsview.py index 7e7d53a4..8c7640b4 100644 --- a/portal/platformsview.py +++ b/portal/platformsview.py @@ -26,6 +26,7 @@ class PlatformsView(FreeAccessView): query = platform_query, query_all = platform_query, checkboxes = False, + init_key = 'platform', datatables_options = { 'iDisplayLength': 10, 'bLengthChange' : True, diff --git a/portal/platformview.py b/portal/platformview.py index 86d282b4..6f537d0c 100644 --- a/portal/platformview.py +++ b/portal/platformview.py @@ -1,11 +1,21 @@ +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" @@ -13,6 +23,7 @@ class PlatformView(FreeAccessView): 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": @@ -23,6 +34,16 @@ class PlatformView(FreeAccessView): .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, @@ -37,17 +58,80 @@ class PlatformView(FreeAccessView): '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 diff --git a/portal/static/css/onelab_marko.css b/portal/static/css/onelab_marko.css index be647a36..d3103994 100644 --- a/portal/static/css/onelab_marko.css +++ b/portal/static/css/onelab_marko.css @@ -18,6 +18,10 @@ table { color:white; } +table.dataTable { + color:black; +} + .container h1, .container h2 { color: #fff !important; diff --git a/portal/templates/platform.html b/portal/templates/platform.html index 48afd944..136a8bfe 100644 --- a/portal/templates/platform.html +++ b/portal/templates/platform.html @@ -5,7 +5,8 @@ {% endblock %} {% block unfold_main %} -

Platform

{{networks}} +
+{{resources}} {% endblock %} diff --git a/portal/validationview.py b/portal/validationview.py index de790341..ad69a2e5 100644 --- a/portal/validationview.py +++ b/portal/validationview.py @@ -141,6 +141,10 @@ class ValidatePendingView(FreeAccessView): 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') @@ -149,6 +153,16 @@ class ValidatePendingView(FreeAccessView): 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