From: Yasin <mohammed-yasin.rahman@lip6.fr>
Date: Mon, 30 Jun 2014 13:54:17 +0000 (+0200)
Subject: Onelab opening last minute changes
X-Git-Tag: myslice-1.1~60^2~19^2~1
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=c0c06b984d835acb246381631c8a2227772a67e7;p=unfold.git

Onelab opening last minute changes
---

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 @@
 				<div id="home-slice-list"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
 			</div>
 		</div>
+		{%if 'is_pi'  in pi %}
 		<div class="col-md-3">
 			<h3>MANAGEMENT</h3>
 			<div>
@@ -31,6 +32,7 @@
 				<button id="validaterequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> Validate Requests</button>
 			</div>
 		</div>
+		 {%endif%}
 		<div class="col-md-3">
 			<h3>
 				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 @@
 							</ul>
 					</div>
 				</li>
+				{%if 'is_pi'  in pi %}	
 				<li id="nav-institution" class=""><a href="/portal/institution">MANAGEMENT</a></li>
+				{%endif%}
 				<li id="nav-request"><a href="/portal/validate">REQUESTS</a></li>
 				<li><a href="/portal/support/">SUPPORT</a></li>
 				
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,