X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fhomeview.py;h=1fe1d2a35ef626ea0b126800c78cfe7892d5712e;hb=e88414306ccca0b2dec66c61200b125192d4f1f2;hp=f1ac37ccacf007752ca077b3a8219c862fb9f385;hpb=5a690e87a71059403fe3872a5a11b437f22f0438;p=unfold.git diff --git a/portal/homeview.py b/portal/homeview.py index f1ac37cc..1fe1d2a3 100644 --- a/portal/homeview.py +++ b/portal/homeview.py @@ -17,9 +17,11 @@ 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 +from portal.actions import authority_check_pis -import json +import json, time import activity.user class HomeView (FreeAccessView, ThemeView): @@ -88,17 +90,23 @@ class HomeView (FreeAccessView, ThemeView): 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" - else: - pi = "is_pi" + #if acc_auth_cred=={} or acc_auth_cred=='N/A': + # pi = "is_not_pi" + #else: + # pi = "is_pi" + user_email = str(self.request.user) + pi = authority_check_pis(self.request, user_email) # check if the user has creds or not 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(): @@ -151,16 +159,21 @@ class HomeView (FreeAccessView, ThemeView): 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" - else: - pi = "is_pi" - + #if acc_auth_cred=={} or acc_auth_cred=='N/A': + # pi = "is_not_pi" + #else: + # pi = "is_pi" + user_email = str(self.request.user) + pi = authority_check_pis(self.request, user_email) # check if the user has creds or not 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 = []