From: Yasin Date: Fri, 21 Mar 2014 14:32:29 +0000 (+0100) Subject: Institution: restrict button visibilities based on user status [pi/use] X-Git-Tag: myslice-1.1~177^2~2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=20bf3e41d306603b85e85c3f7ca2816b28c668ae;p=myslice.git Institution: restrict button visibilities based on user status [pi/use] --- diff --git a/portal/institution.py b/portal/institution.py index 30ef1867..6c55517d 100644 --- a/portal/institution.py +++ b/portal/institution.py @@ -53,11 +53,29 @@ class InstitutionView (FreeAccessView, ThemeView): env['user_details'] = {'parent_authority': user_local_authority} except Exception,e: env['error'] = "Please check your Manifold user config" + ## check user is pi or not + platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled') + account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config') + platform_details = execute_query(self.request, platform_query) + account_details = execute_query(self.request, account_query) + for platform_detail in platform_details: + for account_detail in account_details: + if platform_detail['platform_id'] == account_detail['platform_id']: + if 'config' in account_detail and account_detail['config'] is not '': + account_config = json.loads(account_detail['config']) + if 'myslice' in platform_detail['platform']: + acc_auth_cred = account_config.get('delegated_authority_credentials','N/A') + # assigning values + if acc_auth_cred == {}: + pi = "is_not_pi" + else: + pi = "is_pi" + else: env['person'] = None env['theme'] = self.theme - + env['pi'] = pi env['username']=the_user(request) env['topmenu_items'] = topmenu_items(None, request) if state: env['state'] = state diff --git a/portal/templates/institution.html b/portal/templates/institution.html index 7a84e9b2..ea404fca 100644 --- a/portal/templates/institution.html +++ b/portal/templates/institution.html @@ -29,13 +29,19 @@
Loading Slices
+ {%if 'is_pi' in pi %}
+ {%endif%}
+ {%if 'is_pi' in pi %} + {%else%} + + {%endif%}
Loading Slices
diff --git a/portal/templates/onelab/onelab_institution.html b/portal/templates/onelab/onelab_institution.html index f7c81876..ad4f236e 100644 --- a/portal/templates/onelab/onelab_institution.html +++ b/portal/templates/onelab/onelab_institution.html @@ -22,10 +22,10 @@
Loading Authority
@@ -33,13 +33,19 @@
Loading Slices
+ {%if 'is_pi' in pi %}
+ {%endif%}
+ {%if 'is_pi' in pi %} + {%else%} + + {%endif%}
Loading Slices
@@ -74,44 +82,6 @@ authority_row = "
"; authority_row += "
"; authority_row += "authority: "+val.authority_hrn+"
"; - authority_row += "
"; - authority_row += ""+val.name+"
"; - authority_row += "
"; - authority_row += "Address: "+val.address+"
"; - authority_row += "City: "+val.postcode+" "+val.city+"
"; - authority_row += "
"; - authority_row += "Country: "+val.country+"
"; - authority_row += "
"; - authority_row += "
"; - authority_row += "

Contacts

"; - authority_row += "Legal: "; - /* - - TODO: find a way to express JSON correctly given the constrains: CSV / JSON - - legal = jQuery.parseJSON(val.legal); - if($.isArray(legal)){ - $.each(legal, function(k,v){ - authority_row += k+" "+v+"
"; - }); - }else{ - */ - authority_row += val.legal+"
"; - //} - authority_row += "
"; - authority_row += "Scientific: "; - /* - scientific = jQuery.parseJSON(val.scientific); - if($.isArray(scientific)){ - $.each(scientific, function(v){ - authority_row += v+", "; - }); - }else{ - */ - authority_row += val.scientific+"
"; - //} - onelab_membership = "Status: "+val.onelab_membership; - onelab_data.push(onelab_membership); authority_data.push(authority_row); }); $("div#authority-data").html(authority_data.join( "" ));