From c0c06b984d835acb246381631c8a2227772a67e7 Mon Sep 17 00:00:00 2001 From: Yasin Date: Mon, 30 Jun 2014 15:54:17 +0200 Subject: [PATCH] Onelab opening last minute changes --- portal/homeview.py | 24 +++++++++++++++++++ portal/templates/onelab/onelab_home-view.html | 2 ++ .../onelab/onelab_widget-topmenu.html | 2 ++ portal/templates/registration_view.html | 12 ++++++++++ 4 files changed, 40 insertions(+) diff --git a/portal/homeview.py b/portal/homeview.py index 1097570c..80e93478 100644 --- a/portal/homeview.py +++ b/portal/homeview.py @@ -5,6 +5,7 @@ from django.contrib.auth import authenticate, login, logout from django.template import RequestContext from django.shortcuts import render_to_response from django.shortcuts import render +import json from unfold.loginrequired import FreeAccessView @@ -60,6 +61,29 @@ class HomeView (FreeAccessView, ThemeView): if request.user.is_authenticated(): env['person'] = self.request.user env['username'] = self.request.user + + ## 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" + + print "testing" + print pi + + env['pi'] = pi else: env['person'] = None return render_to_response(self.template,env, context_instance=RequestContext(request)) diff --git a/portal/templates/onelab/onelab_home-view.html b/portal/templates/onelab/onelab_home-view.html index 11fa2ee3..15038cac 100644 --- a/portal/templates/onelab/onelab_home-view.html +++ b/portal/templates/onelab/onelab_home-view.html @@ -22,6 +22,7 @@
Loading Slices
+ {%if 'is_pi' in pi %}

MANAGEMENT

@@ -31,6 +32,7 @@
+ {%endif%}

SUPPORT diff --git a/portal/templates/onelab/onelab_widget-topmenu.html b/portal/templates/onelab/onelab_widget-topmenu.html index e81121b7..c0dbad37 100644 --- a/portal/templates/onelab/onelab_widget-topmenu.html +++ b/portal/templates/onelab/onelab_widget-topmenu.html @@ -19,7 +19,9 @@

+ {%if 'is_pi' in pi %} + {%endif%}
  • SUPPORT
  • diff --git a/portal/templates/registration_view.html b/portal/templates/registration_view.html index 3cdbecf3..654f79d6 100644 --- a/portal/templates/registration_view.html +++ b/portal/templates/registration_view.html @@ -487,6 +487,18 @@ jQuery(document).ready(function(){ {value:"",label:"No authority found !!!"} {% endif %} ]; + // sorting the list + availableTags.sort(function(a,b){ + var nameA=a.value.toLowerCase(), nameB=b.value.toLowerCase(); + if (nameA < nameB) { + return -1; + } + if (nameA > nameB) { + return 1; + } + return 0; + }); + // auto-complete the form jQuery( "#authority_hrn" ).autocomplete({ source: availableTags, minLength: 0, -- 2.43.0