Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
authorCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Tue, 1 Jul 2014 09:30:36 +0000 (11:30 +0200)
committerCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Tue, 1 Jul 2014 09:30:36 +0000 (11:30 +0200)
portal/homeview.py
portal/registrationview.py
portal/templates/base.html
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 13b6961..46c64b1 100644 (file)
@@ -50,6 +50,7 @@ class RegistrationView (FreeAccessView, ThemeView):
         page.add_css_files ( [ "https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" ] )
 
         if method == 'POST':
+            reg_form = {}
             # The form has been submitted
             
             # get the domain url
@@ -152,6 +153,12 @@ class RegistrationView (FreeAccessView, ThemeView):
 
         else:
             user_request = {}
+            ## this is coming from onelab website onelab.eu
+            reg_form = {
+                'first_name':  wsgi_request.GET.get('first_name', ''),
+                'last_name': wsgi_request.GET.get('last_name', ''),
+                'email': wsgi_request.GET.get('email', ''),
+                }
 
         template_env = {
           'topmenu_items': topmenu_items_live('Register', page),
@@ -160,5 +167,6 @@ class RegistrationView (FreeAccessView, ThemeView):
           'theme': self.theme
           }
         template_env.update(user_request)
+        template_env.update(reg_form)
         template_env.update(page.prelude_env ())
         return render(wsgi_request, self.template,template_env)
index de62043..5989508 100644 (file)
@@ -8,6 +8,7 @@
 {% include 'messages-transient-header.html' %}
 <script type="text/javascript"> {# raw js code - use {% insert prelude_js %} ... {% endinsert %} #} {% container prelude_js %}</script>
 <script src="{{ STATIC_URL }}js/jquery.dataTables.min.js"></script>
+<script src="{{ STATIC_URL }}js/jquery.qtip.min.js"></script>
 <script src="{{ STATIC_URL }}js/bootstrap.datatables.js"></script>
 <!-- <script src="{{ STATIC_URL }}js/stash.min.js"></script> -->
 <script src="{{ STATIC_URL }}js/myslice.js"></script>
@@ -31,6 +32,8 @@
 {% insert_str prelude "css/topmenu.css" %}
 {% insert_str prelude "js/logout.js" %}
 <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/{{ theme }}.css">
+<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/jquery.qtip.min.css">
+
 
 <script type="text/javascript">
 /*
@@ -49,7 +52,8 @@ $(document).ready(function() {
             if(data.length > 0){
                 drawSlices(data[0].slices);  
             }else{
-               $("div#home-slice-list").html("<div>no slice</div>");
+               $("div#home-slice-list").html(
+                                       "<div>You do not yet have a slice</div>");
                        $("ul#dropdown-slice-list").append("<li>no slice</li>");
                 slices.push("no slice");
             }
@@ -60,6 +64,7 @@ $(document).ready(function() {
     }
     function drawSlices(slices){
         var items = [];
+               
         $.each( slices, function(i, val) {
             items.push( "<li><a href=\"/slice/"+val+"\">" + val + "</a></li>" );
         });
@@ -67,6 +72,7 @@ $(document).ready(function() {
         $("ul#dropdown-slice-list").append(items.join( "" ));
     }
     {% endif %}
+       jQuery('[title!=""]').qtip();
 });
 </script>
 </head>
index 11fa2ee..87f3b14 100644 (file)
                        <div>
                                <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request Slice</button>
                        </div>
+                       <div>
+                       <p title="A slice is a set of testbed resources on which you can conduct an experiment. 
+                       Either ask your colleagues to give you access to an existing slice or request a new slice now.">
+                       <strong>Your slices</strong></p>
+                       </div>
                        <div>   
                                <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 +37,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
@@ -57,7 +64,7 @@
                                {% if person.last_name %}
                                        {{person.first_name}} {{person.last_name}}<br />
                                {% endif %}
-                       <span class="label">Email:</span> <a href='/portal/account/'>{{person.email}}</a>
+                       <span class="label">Username:</span> <a href='/portal/account/' title="Click here to see and edit your account details.">{{person.email}}</a>
                </div>
                </div>
        </div>
index e81121b..5a6a19b 100644 (file)
                                                        </ul>
                                        </div>
                                </li>
+                               {%if 'is_pi'  in pi %}  
                                <li id="nav-institution" class=""><a href="/portal/institution">MANAGEMENT</a></li>
                                <li id="nav-request"><a href="/portal/validate">REQUESTS</a></li>
+                                {%endif%}
                                <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,