From 6dcca4d4a7f11dff9962a1a3fc14ea1969e334f2 Mon Sep 17 00:00:00 2001 From: Loic Baron Date: Mon, 1 Sep 2014 18:58:12 +0200 Subject: [PATCH] Manage Institution page: improved display and quick loading using explicit fields in the Queries, fields myplc VS fields Registry Only --- portal/managementtababout.py | 15 +++++++----- .../templates/onelab/onelab_institution.html | 16 ++++++++----- .../onelab/onelab_management-tab-about.html | 24 ++++++++++++++++++- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/portal/managementtababout.py b/portal/managementtababout.py index cee93118..8bd1cdc1 100644 --- a/portal/managementtababout.py +++ b/portal/managementtababout.py @@ -28,8 +28,9 @@ class ManagementAboutView (FreeAccessView, ThemeView): user_local_query = Query().get('local:user').select('config').filter_by('email','==',str(self.request.user)) user_local_details = execute_query(self.request, user_local_query) user_authority = json.loads(user_local_details[0]['config']).get('authority') - - authority_query = Query().get('authority').select('description', 'authority_hrn', 'legal', 'address', 'abbreviated_name', + # XXX Should be done using Metadata + # select column.name from local:object where table=='authority' + authority_query = Query().get('authority').select('authority_hrn', 'name', 'address', 'enabled','description', 'scientific', 'city', 'name', 'url', 'country', 'enabled', 'longitude', 'tech', 'latitude', 'pi_users', 'parent_authority', 'onelab_membership', 'postcode').filter_by('authority_hrn','==',user_authority) @@ -37,11 +38,13 @@ class ManagementAboutView (FreeAccessView, ThemeView): if authority_details : authority_contacts = {} - authority_contacts['scientific'] = [ x.strip()[1:-1] for x in authority_details[0]['scientific'][1:-1].split(',') ] - authority_contacts['technical'] = [ x.strip()[1:-1] for x in authority_details[0]['tech'][1:-1].split(',') ] - - authority_contacts['legal'] = [ x.strip().replace('"','') for x in authority_details[0]['legal'][1:-1].split(',') ] authority = authority_details[0] + if 'scientific' in authority and authority['scientific'] is not None: + authority_contacts['scientific'] = [ x.strip()[1:-1] for x in authority['scientific'][1:-1].split(',') ] + if 'technical' in authority and authority['technical'] is not None: + authority_contacts['technical'] = [ x.strip()[1:-1] for x in authority['tech'][1:-1].split(',') ] + if 'legal' in authority and authority['legal'] is not None: + authority_contacts['legal'] = [ x.strip().replace('"','') for x in authority['legal'][1:-1].split(',') ] else : authority_contacts = None authority = None diff --git a/portal/templates/onelab/onelab_institution.html b/portal/templates/onelab/onelab_institution.html index c8a668f1..bd361de2 100644 --- a/portal/templates/onelab/onelab_institution.html +++ b/portal/templates/onelab/onelab_institution.html @@ -39,9 +39,11 @@ +/- Email User hrn + @@ -65,7 +67,7 @@ Users Url - Expiration + Creation @@ -90,7 +92,7 @@ $(document).ready(function() { {% if person %} {% if user_details.parent_authority %} - $.post("/rest/slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) { + $.post("/rest/slice/",{'fields':['slice_hrn','users','url','slice_date_created'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) { var list_slices = []; var table_slices = []; /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */ @@ -108,10 +110,10 @@ $(document).ready(function() { users_length=val.users.length; } - if(val.slice_url=="undefined" || val.slice_url==null){ + if(val.url=="undefined" || val.url==null){ slice_url=""; }else{ - slice_url=""+val.slice_url+""; + slice_url=""+val.url+""; } slice_row = ""; @@ -120,7 +122,7 @@ $(document).ready(function() { slice_row += ""+users_length+""; slice_row += ""+slice_url+""; //slice_row += ""+nodes_length+""; - slice_row += ""+val.slice_expires+""; + slice_row += ""+val.slice_date_created+""; slice_row += ""; table_slices.push(slice_row); @@ -133,7 +135,7 @@ $(document).ready(function() { }); - $.post("/rest/user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) { + $.post("/rest/user/",{'fields':['user_hrn','user_email'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) { var list_users = []; var table_users = []; /* Available fields @@ -146,9 +148,11 @@ $(document).ready(function() { user_row += ""; user_row += ""+val.user_email+""; user_row += ""+val.user_hrn+""; + /* user_row += ""+val.user_first_name+""; user_row += ""+val.user_last_name+""; user_row += ""+val.user_enabled+""; + */ user_row += ""; table_users.push(user_row); }); diff --git a/portal/templates/onelab/onelab_management-tab-about.html b/portal/templates/onelab/onelab_management-tab-about.html index 687b7de3..bc768a69 100644 --- a/portal/templates/onelab/onelab_management-tab-about.html +++ b/portal/templates/onelab/onelab_management-tab-about.html @@ -4,19 +4,36 @@ {{authority.name}}
+ {% if authority.name and authority.url %}

{{authority.name}}

+ {% elif authority.name %} +

{{authority.name}}

+ {% endif %}

+ {% if authority.address %} {{authority.address}}
- {{authority.postcode}} {{authority.city}}
+ {% endif %} + {% if authority.postcode %} + {{authority.postcode}} + {% endif %} + {% if authority.address %} + {{authority.city}}
+ {% endif %} + {% if authority.address %} {{authority.country}} + {% endif %}


+ + {% if authority.address %}

Onelab membership

{{ authority.onelab_membership }}

+ {% endif %}
+ {% if authority.legal %}

Legal Contact:

{% for c in authority_contacts.legal %} @@ -24,6 +41,8 @@ {% endfor %}


+ {% endif %} + {% if authority.scientific %}

Scientific Contact:

{% for c in authority_contacts.scientific %} @@ -31,12 +50,15 @@ {% endfor %}


+ {% endif %} + {% if authority.technical %}

Technical Contact:

{% for c in authority_contacts.technical %} {{ c }}
{% endfor %}

+ {% endif %}