Merge branch 'fibre' of ssh://git.onelab.eu/git/myslice into fibre
[myslice.git] / portal / homeview.py
index cf3fcba..718ba60 100644 (file)
@@ -64,8 +64,8 @@ class HomeView (FreeAccessView, ThemeView):
        #################################################
        ## first you must open a connection to the server
        try:
-               # Connect to NOC
-               l = ldap.initialize("ldap://10.128.0.50:389")
+               # Connect to UFRJ
+                l = ldap.initialize("ldap://200.130.15.186:389")
                # Bind/authenticate with a root user to search all objects
                l.simple_bind_s("cn=Manager,dc=br,dc=fibre","fibre2013")
                
@@ -316,8 +316,9 @@ class HomeView (FreeAccessView, ThemeView):
         else:
             # log user activity
             #activity.user.login(self.request, "error")
-            env['state'] = "Your username and/or password were incorrect."
-            
+
+           env['state'] = "Your username and/or password were incorrect."
+
             return render_to_response(self.template, env, context_instance=RequestContext(request))
 
     def get (self, request, state=None):
@@ -335,15 +336,16 @@ class HomeView (FreeAccessView, ThemeView):
             # 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_detail:
-                        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')
-                                    acc_user_cred = account_config.get('delegated_user_credential','N/A')
+            if platform_details is not None and platform_details != {}:
+                for platform_detail in platform_details:
+                    for account_detail in account_details:
+                        if 'platform_id' in platform_detail:
+                            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')
+                                        acc_user_cred = account_config.get('delegated_user_credential','N/A')
             # assigning values
             if acc_auth_cred=={} or acc_auth_cred=='N/A':
                 pi = "is_not_pi"