Expired User Credential message on the HomeView and AccountView
authorLoic Baron <loic.baron@lip6.fr>
Thu, 20 Nov 2014 15:22:11 +0000 (16:22 +0100)
committerLoic Baron <loic.baron@lip6.fr>
Thu, 20 Nov 2014 15:22:11 +0000 (16:22 +0100)
portal/accountview.py
portal/homeview.py
portal/templates/onelab/onelab_account-view.html
portal/templates/onelab/onelab_home-view.html

index 5048383..325796b 100644 (file)
@@ -16,8 +16,9 @@ from django.contrib.auth.decorators     import login_required
 
 from myslice.theme import ThemeView
 
+from portal.account                     import Account, get_expiration
 #
-import json, os, re, itertools
+import json, os, re, itertools, time
 from OpenSSL import crypto
 from Crypto.PublicKey import RSA
 
@@ -210,7 +211,11 @@ class AccountView(LoginRequiredAutoLogoutView, ThemeView):
         if acc_user_cred == {} or acc_user_cred == 'N/A':
             user_cred = 'no_creds'
         else:
-            user_cred = 'has_creds'
+            exp_date = get_expiration(acc_user_cred, 'timestamp')
+            if exp_date < time.time():
+                user_cred = 'creds_expired'
+            else:
+                user_cred = 'has_creds'
 
         context = super(AccountView, self).get_context_data(**kwargs)
         context['principal_acc'] = principal_acc_list
index f1ac37c..3e9514f 100644 (file)
@@ -17,9 +17,10 @@ from ui.topmenu                         import topmenu_items, the_user
 from myslice.configengine               import ConfigEngine
 
 from myslice.theme                      import ThemeView
+from portal.account                     import Account, get_expiration
 from portal.models                      import PendingSlice
 
-import json
+import json, time
 import activity.user
 
 class HomeView (FreeAccessView, ThemeView):
@@ -97,8 +98,12 @@ class HomeView (FreeAccessView, ThemeView):
                     if acc_user_cred == {} or acc_user_cred == 'N/A':
                         user_cred = 'no_creds'
                     else:
-                        user_cred = 'has_creds'
-                    
+                        exp_date = get_expiration(acc_user_cred, 'timestamp')
+                        if exp_date < time.time():
+                            user_cred = 'creds_expired'
+                        else:
+                            user_cred = 'has_creds'
+
                     # list the pending slices of this user
                     pending_slices = []
                     for slices in PendingSlice.objects.filter(type_of_nodes__iexact=self.request.user).all():
@@ -160,7 +165,11 @@ class HomeView (FreeAccessView, ThemeView):
             if acc_user_cred == {} or acc_user_cred == 'N/A':
                 user_cred = 'no_creds'
             else:
-                user_cred = 'has_creds'
+                exp_date = get_expiration(acc_user_cred, 'timestamp')
+                if exp_date < time.time():
+                    user_cred = 'creds_expired'
+                else:
+                    user_cred = 'has_creds'
 
             # list the pending slices of this user
             pending_slices = []
index 549ec6b..7ac9578 100644 (file)
@@ -9,7 +9,10 @@
        </div>
         {%if 'no_creds'  in user_cred %}
     <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">NO CREDENTIALS</a> are delegated to the portal!</p>
-{%endif%}
+    {%endif%}
+        {%if 'creds_expired'  in user_cred %}
+    <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">EXPIRED CREDENTIALS</a> Please delegate again your credentials to the portal!</p>
+    {%endif%}
 
 </div>
 {% if messages %}
index 944bcbe..9170b4a 100644 (file)
@@ -51,6 +51,9 @@
           {%if 'no_creds'  in user_cred %}
       <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">NO CREDENTIALS</a> are delegated to the portal!</p>
   {%endif%}
+        {%if 'creds_expired'  in user_cred %}
+    <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">EXPIRED CREDENTIALS</a> Please delegate again your credentials to the portal!</p>
+    {%endif%}
 
        <div class="row">
                {%if 'is_pi'  in pi %}
                $('button#slicerequestbtn').click(function() {
                        window.location="/portal/slice_request/";
                });
-/*-------
-List of slices has been moved in 
-portal/templates/base.html
-This should go into session
---------*/
+
+        /*
+            Launch queries to get the resources and leases in Manifold Cache
+        */
+            
+        $.post("/rest/resource/", function( data ) {
+        });
+        $.post("/rest/lease/", function( data ) {
+        });
+        
+        /*-------
+        List of slices has been moved in 
+        portal/templates/base.html
+        This is now in localStorage 
+        --------*/
+        // myslice.user is in LocalStorage
+        if(myslice.user.slices.length>0){
+            $.each( myslice.user.slices, function(i, val) {
+                /*
+                Launch a Query for each slice to get resources and leases in Manifold Cache
+                */
+                $.post("/rest/slice/", { 'filters': { 'slice_hrn' : val } }, function(data) {
+                });
+            });
+        }
 });
 </script>
 {# widget "_widget-monitor.html" #}