From: Loic Baron Date: Thu, 20 Nov 2014 15:22:11 +0000 (+0100) Subject: Expired User Credential message on the HomeView and AccountView X-Git-Tag: myslice-1.1~13^2~7^2 X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=95acb4a32b2a19bbf47e7f3f4de462e8f07e0327 Expired User Credential message on the HomeView and AccountView --- diff --git a/portal/accountview.py b/portal/accountview.py index 50483839..325796bc 100644 --- a/portal/accountview.py +++ b/portal/accountview.py @@ -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 diff --git a/portal/homeview.py b/portal/homeview.py index f1ac37cc..3e9514f3 100644 --- a/portal/homeview.py +++ b/portal/homeview.py @@ -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 = [] diff --git a/portal/templates/onelab/onelab_account-view.html b/portal/templates/onelab/onelab_account-view.html index 549ec6b4..7ac95782 100644 --- a/portal/templates/onelab/onelab_account-view.html +++ b/portal/templates/onelab/onelab_account-view.html @@ -9,7 +9,10 @@ {%if 'no_creds' in user_cred %}

NO CREDENTIALS are delegated to the portal!

-{%endif%} + {%endif%} + {%if 'creds_expired' in user_cred %} +

EXPIRED CREDENTIALS Please delegate again your credentials to the portal!

+ {%endif%} {% if messages %} diff --git a/portal/templates/onelab/onelab_home-view.html b/portal/templates/onelab/onelab_home-view.html index 944bcbe6..9170b4af 100644 --- a/portal/templates/onelab/onelab_home-view.html +++ b/portal/templates/onelab/onelab_home-view.html @@ -51,6 +51,9 @@ {%if 'no_creds' in user_cred %}

NO CREDENTIALS are delegated to the portal!

{%endif%} + {%if 'creds_expired' in user_cred %} +

EXPIRED CREDENTIALS Please delegate again your credentials to the portal!

+ {%endif%}
{%if 'is_pi' in pi %} @@ -232,11 +235,31 @@ $('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) { + }); + }); + } }); {# widget "_widget-monitor.html" #}