From 8e6372eabf1db28adf273c33408c672b56e42e49 Mon Sep 17 00:00:00 2001 From: Yasin Date: Tue, 1 Jul 2014 12:21:53 +0200 Subject: [PATCH] fix: topmenu for pi and non pi --- portal/homeview.py | 39 +++++++------ portal/templates/onelab/onelab_home-view.html | 56 ++++++++++++++++++- 2 files changed, 73 insertions(+), 22 deletions(-) diff --git a/portal/homeview.py b/portal/homeview.py index ce12ee26..49aad8f6 100644 --- a/portal/homeview.py +++ b/portal/homeview.py @@ -100,27 +100,26 @@ class HomeView (FreeAccessView, ThemeView): def get (self, request, state=None): env = self.default_env() - ## 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" + if request.user.is_authenticated(): + ## 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" - - env['pi'] = pi - if request.user.is_authenticated(): + env['pi'] = pi env['person'] = self.request.user else: env['person'] = None diff --git a/portal/templates/onelab/onelab_home-view.html b/portal/templates/onelab/onelab_home-view.html index 87f3b14e..ff6ec256 100644 --- a/portal/templates/onelab/onelab_home-view.html +++ b/portal/templates/onelab/onelab_home-view.html @@ -8,6 +8,7 @@ {% if username %}
+ {%if 'is_pi' in pi %}

EXPERIMENT @@ -27,7 +28,6 @@
Loading Slices

- {%if 'is_pi' in pi %}

MANAGEMENT

@@ -37,7 +37,6 @@
- {%endif%}

SUPPORT @@ -68,6 +67,59 @@

+ {%else%} +
+
+

+ EXPERIMENT +

+
+ +
+
+ +
+
+

+ Your slices

+
+
+
Loading Slices
+
+
+
+

+ SUPPORT +

+
+ +
+
+ +
+
+ +
+

+ ACCOUNT +

+
+ +
+
+ +
+
+ {% if person.last_name %} + {{person.first_name}} {{person.last_name}}
+ {% endif %} + Username: {{person.email}} +
+
+
+ {%endif%} + {% else %}
-- 2.43.0