Onelab opening last minute changes
authorYasin <mohammed-yasin.rahman@lip6.fr>
Mon, 30 Jun 2014 13:54:17 +0000 (15:54 +0200)
committerYasin <mohammed-yasin.rahman@lip6.fr>
Mon, 30 Jun 2014 13:54:17 +0000 (15:54 +0200)
portal/homeview.py
portal/templates/onelab/onelab_home-view.html
portal/templates/onelab/onelab_widget-topmenu.html
portal/templates/registration_view.html

index 1097570..80e9347 100644 (file)
@@ -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))
index 11fa2ee..15038ca 100644 (file)
@@ -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
index e81121b..c0dbad3 100644 (file)
@@ -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>
                                
index 3cdbecf..654f79d 100644 (file)
@@ -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,