X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fhomeview.py;h=b0249ce8cf37618882fb49aa7281e5058470a1f6;hb=8441a4b2b81aa0543fa048b6ad2a59934c368769;hp=ce12ee263dda430c088b9ff421bb0fa498494183;hpb=5ff398d7f973cb4c813dfa3b1c57378315310787;p=myslice.git diff --git a/portal/homeview.py b/portal/homeview.py index ce12ee26..b0249ce8 100644 --- a/portal/homeview.py +++ b/portal/homeview.py @@ -75,14 +75,11 @@ class HomeView (FreeAccessView, ThemeView): if 'myslice' in platform_detail['platform']: acc_auth_cred = account_config.get('delegated_authority_credentials','N/A') # assigning values - if acc_auth_cred == {}: + if acc_auth_cred=={} or acc_auth_cred=='N/A': pi = "is_not_pi" else: pi = "is_pi" - print "testing" - print pi - env['pi'] = pi else: env['person'] = None @@ -100,27 +97,30 @@ 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" + acc_auth_cred={} + if request.user.is_authenticated(): + acc_auth_cred='N/A' + ## 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') + # XXX Something like an invalid session seems to make the execute fail sometimes, and thus gives an error on the main page + 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_id' in platform_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=={} or acc_auth_cred=='N/A': + 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