Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
authorLoic Baron <loic.baron@lip6.fr>
Wed, 21 Jan 2015 14:37:05 +0000 (15:37 +0100)
committerLoic Baron <loic.baron@lip6.fr>
Wed, 21 Jan 2015 14:37:05 +0000 (15:37 +0100)
portal/institution.py
portal/registrationview.py
portal/static/js/myslice.js
portal/templates/base.html
portal/templates/fed4fire/fed4fire_home-view.html
portal/templates/fed4fire/fed4fire_institution.html [deleted file]
portal/templates/fed4fire/fed4fire_registration_view.html
portal/templates/institution.html
portal/templates/onelab/onelab_institution.html [deleted file]
portal/urls.py
rest/__init__.py

index ccdb625..cf0055c 100644 (file)
@@ -30,29 +30,32 @@ class InstitutionView (LoginRequiredAutoLogoutView, ThemeView):
         env['theme'] = self.theme
         return render_to_response(self.template, env, context_instance=RequestContext(request))
 
-    def get (self, request, state=None):
+    def get (self, request, authority_hrn=None, state=None):
+        print " -----  institution",authority_hrn
         env = self.default_env()
-
         if request.user.is_authenticated(): 
             env['person'] = self.request.user
-            user_query  = Query().get('myslice:user').select('user_hrn','parent_authority').filter_by('user_hrn','==','$user_hrn')
-            user_details = execute_query(self.request, user_query)
-            try:
-                env['user_details'] = user_details[0]
-            except Exception,e:
-                env['error'] = "Please check your Credentials"
-            
-            try:
-                user_local_query  = Query().get('local:user').select('config').filter_by('email','==',str(env['person']))
-                user_local_details = execute_query(self.request, user_local_query)
-                user_local = user_local_details[0]            
-                user_local_config = user_local['config']
-                user_local_config = json.loads(user_local_config)
-                user_local_authority = user_local_config.get('authority')
-                if 'user_details' not in env or 'parent_authority' not in env['user_details'] or env['user_details']['parent_authority'] is None:
-                    env['user_details'] = {'parent_authority': user_local_authority}
-            except Exception,e:
-                env['error'] = "Please check your Manifold user config"
+            if authority_hrn is None: 
+                user_query  = Query().get('myslice:user').select('user_hrn','parent_authority').filter_by('user_hrn','==','$user_hrn')
+                user_details = execute_query(self.request, user_query)
+                try:
+                    env['user_details'] = user_details[0]
+                except Exception,e:
+                    # If the Query fails, check in local DB 
+                    try:
+                        user_local_query  = Query().get('local:user').select('config').filter_by('email','==',str(env['person']))
+                        user_local_details = execute_query(self.request, user_local_query)
+                        user_local = user_local_details[0]            
+                        user_local_config = user_local['config']
+                        user_local_config = json.loads(user_local_config)
+                        user_local_authority = user_local_config.get('authority')
+                        if 'user_details' not in env or 'parent_authority' not in env['user_details'] or env['user_details']['parent_authority'] is None:
+                            env['user_details'] = {'parent_authority': user_local_authority}
+                    except Exception,e:
+                        env['error'] = "Please check your Credentials"
+            else:
+                env['project'] = True
+                env['user_details'] = {'parent_authority': authority_hrn}
             ## 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')
index d5d3b97..47ae6c9 100644 (file)
@@ -45,6 +45,7 @@ class RegistrationView (FreeAccessView, ThemeView):
         authorities_query = Query.get('authority').select('name', 'authority_hrn')
         authorities = execute_admin_query(wsgi_request, authorities_query)
         if authorities is not None:
+            authorities = sorted(authorities, key=lambda k: k['authority_hrn'])
             authorities = sorted(authorities, key=lambda k: k['name'])
         
         print "############ BREAKPOINT 1 #################"
index 1ccc1c1..4b8fc83 100644 (file)
@@ -1,6 +1,10 @@
 /*
  * MySlice Class
  */
+function isFunction(functionToCheck) {
+ var getType = {};
+ return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
+}
 
 function list() {
        this.elements = [];
@@ -114,6 +118,20 @@ var myslice = {
                }
                return this.user;
        },
+       projects: {},
+       
+       projects: function() {
+               if ($.isEmptyObject(this.projects)) {
+                       //this.login(function() { return this.user; });
+            if(localStorage.getItem('projects')!='undefined'){
+                           this.projects = JSON.parse(localStorage.getItem('projects'));
+            }else{
+                return false;
+            }
+               }
+               return this.projects;
+       },
+
     loadSlices: function(slices) {
         if (typeof(slices) == "undefined"){
 
@@ -154,12 +172,43 @@ var myslice = {
         if($.isEmptyObject(user)){
             // REGISTRY ONLY TO BE REMOVED WITH MANIFOLD-V2
                    $.post("/rest/myslice:user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) {
-                           //myslice.user = new user(data[0]);
                            localStorage.setItem('user', JSON.stringify(data[0]));
                 myslice.loadSlices(data[0].slices);
+                if(isFunction(fn)){
+                    fn();
+                }
                    });
+        }else{
+            if(isFunction(fn)){
+                fn();
+            }
+        }
+
+       },
+       loadProjects: function(fn) {
+        user = JSON.parse(localStorage.getItem('user'));
+        projects = localStorage.getItem('projects');
+        if($.isEmptyObject(projects)){
+            if($.isEmptyObject(user) || $.isEmptyObject(user.parent_authority)){
+                       $.post("/rest/myslice:user/",{'filters':{'user_hrn':'$user_hrn'},'fields':['parent_authority']}, function( data ) {
+                    parent_authority = data[0].parent_authority;
+
+                });
+            }else{
+                parent_authority = user.parent_authority;
+            }
+            // REGISTRY ONLY TO BE REMOVED WITH MANIFOLD-V2
+            $.post("/rest/authority/",{'fields':['authority_hrn'],'filters':{'authority_hrn':'CONTAINS'+parent_authority}}, function( data ) {
+                localStorage.setItem('projects', JSON.stringify(data));
+            });
+        }else{
+            if(isFunction(fn)){
+                fn();
+            }
         }
+
        },
+
     getSlices: function(name) {
        
     },
index 0bf9ab4..decc1b3 100644 (file)
@@ -48,48 +48,50 @@ XXX TODO: session
 This list of slices should go into SESSION !
 */
 $(document).ready(function() {
-    {% if username %}
-    myslice.login();
+{% if username %}
+    myslice.login(function(){
+        user = myslice.user();
 
-    user = myslice.user();
+        var slices = [];
+        if($.isEmptyObject(user)){
+            $("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");
+        }else{
+            slices = user.slices;
+            drawSlices(slices);
+        }
+        {% if theme == "fed4fire" %}
+        myslice.loadProjects(function(){
+            p = myslice.projects();
+            drawProjects(p);
+        });
+        {% endif %}
+    });
 
-    var slices = [];
-    if($.isEmptyObject(user)){
-        $.post("/rest/myslice:user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) {
-            if(data.length > 0){
-                drawSlices(data[0].slices);  
-            }else{
-               $("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");
-            }
-       });
-    }else{
-        slices = user.slices;
-        drawSlices(slices);
-    }
-   
-    /*
-        Launch queries to get the resources and leases in Manifold Cache
-    */
-        
     function drawSlices(slices){
         var items = [];
                
         $.each( slices, function(i, val) {
             items.push( "<li><a href=\"/resources/"+val+"\">" + val + "</a></li>" );
-            /*
-            // Launch a Query for each slice to get resources and leases in Manifold Cache
-            // Now only done in Homeview to speed up the other pages
-            $.post("/rest/slice/", { 'filters': { 'slice_hrn' : val } }, function(data) {
-            });
-            */
         });
         $("div#home-slice-list").html($( "<ul/>", { html: items.join( "" ) }));
         $("ul#dropdown-slice-list").append(items.join( "" ));
     }
+    
+    {% if theme == "fed4fire" %}
+    function drawProjects(projects){
+        var items = [];
+               
+        $.each( projects, function(i, val) {
+            items.push( "<li><a href=\"/portal/project/"+val.authority_hrn+"\">" + val.authority_hrn + "</a></li>" );
+        });
+        $("div#home-project-list").html($( "<ul/>", { html: items.join( "" ) }));
+        $("ul#dropdown-project-list").append(items.join( "" ));
+    }
     {% endif %}
+{% endif %}
        jQuery('[title!=""]').qtip();
 });
 </script>
index 385f698..5938eac 100644 (file)
                        <div>
                                <a href="/portal/institution"><img src="{{ STATIC_URL }}img/icon_authority_color.png" alt="" /></a>
                        </div>
+                       <div>
+                               <button id="projectrequestbtn" type="button" class="btn btn-default" style="width:165px;"><span class="glyphicon glyphicon-plus"></span> Join Project</button>
+                       </div>
                        <div>
                                <button id="validaterequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> Validate Requests</button>
                        </div>
+                       <div>
+                               <p><strong>Your projects </strong>
+                                       <span title="A project is a sub-authority under the responsability of your institution gathering users, who will be able to create slices for their experiments."
+                                       class="glyphicon glyphicon-info-sign">
+                               </span>
+                               </p>
+                       </div>
+                       <div>   
+                               <div id="home-project-list"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading projects" /></div>
+                       </div>
+
                </div>
                <div class="col-md-3">
                        <h3>
                        </div>
                        <p></p>
                        <div>
-                       <button id="statbtn" type="button" style="width: 150px;" class="btn btn-default"><span class="glyphicon glyphicon-stats"></span>Testbeds' status</button>
+                       <button id="statbtn" type="button" style="width: 170px;" class="btn btn-default"><span class="glyphicon glyphicon-stats" style="margin-right: 10px;"></span>Testbeds' status</button>
                        </div>
                        <div>
                        <button id="repbtn" type="button" style="width: 170px;" class="btn btn-default"><span class="glyphicon glyphicon-stats"></span>Testbeds' reputation</button>
                $('button#slicerequestbtn').click(function() {
                        window.location="/portal/slice_request/";
                });
+               $('button#projectrequestbtn').click(function() {
+                       window.location="/portal/project_request/";
+               });
 
         myslice.loadSlices();
 });
diff --git a/portal/templates/fed4fire/fed4fire_institution.html b/portal/templates/fed4fire/fed4fire_institution.html
deleted file mode 100644 (file)
index 8e2afbb..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-{% extends "layout_wide.html" %}
-
-{% block head %} 
-<script type="text/javascript" src="{{STATIC_URL}}/js/institution.js"></script>
-{% endblock head %}
-
-{% block content %}
-<div class="container">
-       <div class="row">
-               <div class="col-md-12">
-                        <div class="breadcrumbs">
-                                Management &nbsp;>&nbsp; Institution: <span id="authority_name"></span>
-                        </div>
-               </div>
-       </div>
-</div>
-<div class="container">
-       <div class="row">
-               <div class="col-md-12">
-                       <ul class="nav nav-tabs nav-section">
-                               <li class="active"><a href="#about">About</a></li>
-                               <li><a href="#users">Users</a></li>
-                               <li><a href="#slices">Slices</a></li>
-                               <li><a href="#requests">Requests</a></li>
-                       </ul>
-           </div>
-       </div>
-</div>
-<div class="container tab-content">
-       <div class="tab-pane active row" id="about">
-       </div>
-       
-       <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
-               <div class="col-md-12 el">
-                       <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
-                               <div id="user-tab-loaded" style="display:none;">
-                               <table id="user-tab" class="table">
-                                       <tr>
-                                       <th>+/-</th>
-                                       <th>Email</th>
-                                       <th>User hrn</th>
-                            <!--
-                                       <th>First name</th>
-                                       <th>Last name</th>
-                                       <th>Enabled</th>
-                            -->
-                                       </tr>
-                               </table>
-                               
-                       </div>
-                       {%if 'is_pi'  in pi %}  
-                       <div>
-                               <button id="deleteusers" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected users</button>
-                       </div>
-                       {% endif %}
-               </div>
-       </div>
-
-       <div class="tab-pane row" id="slices">
-               <div class="col-md-12 el">
-           <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
-           <div id="slice-tab-loaded" style="display:none;">
-               <table id="slice-tab" class="table">
-                   <tr>
-                       <th>+/-</th>
-                       <th>Slice hrn</th>
-                       <th>Users</th>
-                       <th>Url</th>
-                       <!-- <th>nodes</th> -->
-                       <th>Creation</th>
-                   </tr>
-               </table>                        
-           </div>
-       {% if 'is_pi'  in pi %}
-        <div>
-               {% if 'is_pi'  in pi %}
-                       <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
-                       {% else %}
-                       <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
-                       {% endif %}
-            <button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
-            <button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
-        </div>
-               {% endif %} 
-          </div>
-       </div>
-       <div class="tab-pane row" id="requests">
-       </div>
-</div>
-<script>
-$(document).ready(function() {
-    {% if person %}
-    {% if user_details.parent_authority %}
-
-        $.post("/rest/myslice:slice/",{'fields':['slice_hrn','users','url','slice_date_created'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
-            var list_slices = [];
-            var table_slices = [];
-            /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */
-            $.each( data, function( key, val ) {
-                list_slices.push( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
-                if(val.nodes=="undefined" || val.nodes==null){
-                    nodes_length=0;
-                }else{
-                    nodes_length=val.nodes.length;
-                }
-                console.log(val);
-                if(val.users=="undefined" || val.users==null){
-                    users_length=0;
-                }else{
-                    users_length=val.users.length;
-                }
-
-                if(val.url=="undefined" || val.url==null){
-                    slice_url="";
-                }else{
-                    slice_url="<a href='"+val.url+"' target='_blank'>"+val.url+"</a>";
-                }
-                
-                slice_row = "<tr id='"+val.slice_hrn+"'>";
-                slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'></td>";
-                slice_row += "<td><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>";
-                slice_row += "<td>"+users_length+"</td>";
-                slice_row += "<td>"+slice_url+"</td>";
-                //slice_row += "<td>"+nodes_length+"</td>";
-                slice_row += "<td>"+val.slice_date_created+"</td>";
-                slice_row += "</tr>";
-                table_slices.push(slice_row);
-                
-            });
-           
-            /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
-            $("table#slice-tab tr:last").after(table_slices.join( "" ));
-            $("div#slice-tab-loaded").css("display","block");
-            $("div#slice-tab-loading").css("display","none");
-        });
-               
-               
-        $.post("/rest/user/",{'fields':['user_hrn','user_email'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
-            var list_users = [];
-            var table_users = [];
-                   /* Available fields
-                   user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
-                   user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
-                   */
-            $.each( data, function( key, val ) {
-                list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
-                user_row = "<tr id='"+val.user_hrn+"'>";
-                user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
-                user_row += "<td>"+val.user_email+"</td>";
-                user_row += "<td>"+val.user_hrn+"</td>";
-                /*
-                user_row += "<td>"+val.user_first_name+"</td>";
-                user_row += "<td>"+val.user_last_name+"</td>";
-                           user_row += "<td>"+val.user_enabled+"</td>";
-                */
-                user_row += "</tr>";
-                table_users.push(user_row);
-            });
-            $("table#user-tab tr:last").after(table_users.join( "" ));
-            $("div#user-tab-loaded").css("display","block");
-            $("div#user-tab-loading").css("display","none");
-        });
-
-    {% endif %}
-    {% endif %}
-
-}); // End document.ready
-
-$(document).ready(function() {
-       $('.nav-tabs a').click(function (e) {
-               e.preventDefault();
-               $(this).tab('show');
-       var id = $(this).attr('href').substr(1);
-       if ((id == 'requests') || (id == 'about'))
-               $("#" + id).load('/management/' + id);
-       });
-       var hash = window.location.hash;
-       if (hash) {
-               $('.nav-tabs a[href='+hash+']').click();
-       } else {
-               $('.nav-tabs a[href=#about]').click();
-       }
-});
-</script>
-{% endblock %}
index de03e3c..6c4bee3 100644 (file)
@@ -42,7 +42,7 @@
                         {% else %}
                             <option value="{{ authority.authority_hrn }}">{{authority.authority_hrn}}</option>
                         {% endif %}
-                    {% endfor %}    
+                    {% endfor %}
                 {% else %}
                     <option value:"">No authority found !!!</option>
                 {% endif %}
 <div class="row">
        <div class="col-md-12">
                <div class="form-group" id="register">
-                       <p></p> 
+                       <p></p>
                <input class="submit btn btn-onelab" type="submit" value="Sign up" />
                </form>
            </div>
 
     
 <script>
-//setting the default value in the org_list
-$(function() {
-    var temp="fed4fire.global"; 
-    $("#org_name").val(temp);
-});
 
 $(document).ready(function(){
+    /*
     var availableTags = [
     {% if authorities %}
         {% for authority in authorities %}
@@ -181,8 +177,24 @@ $(document).ready(function(){
                }
        return 0;
        }); 
+    */
+    
        // auto-complete the form
     jQuery("#org_name").combobox();
+
+    //setting the default value in the org_list
+    var temp="fed4fire.global"; 
+    $("#org_name").val(temp);
+
+    /*
+    // Must be executed in Python as Admin Query - User is not logged in
+
+    $.post("/rest/authority/",{'filters':{'authority_hrn':'CONTAINS'+temp}}, function( data ) {
+        $.each( data, function( key, val ) {
+            console.log(val);
+        });
+    });
+    */
        $('[title!=""]').qtip();
        $("form").validate();
        $("form").submit(function() {
index e2a95ca..f168167 100644 (file)
-{% extends "layout.html" %}
+{% extends "layout_wide.html" %}
 
 {% block head %} 
 <script type="text/javascript" src="{{STATIC_URL}}/js/institution.js"></script>
 {% endblock head %}
 
 {% block content %}
-<div class="row">
-       <div class="col-md-12">
-               <ul class="nav nav-tabs nav-section">
-                       <li class="active"><a href="#info"><img src="{{ STATIC_URL }}icons/authority-xs.png" alt="Institution" /> Institution {{user_details.parent_authority}}</a></li>
-                       <li><a href="#users">Users</a></li>
-                       <li><a href="#slices">Slices</a></li>
-               </ul>
-    </div>
+<div class="container">
+       <div class="row">
+               <div class="col-md-12">
+                        <div class="breadcrumbs">
+                                Management &nbsp;>&nbsp; Institution: <span id="authority_name"></span>
+                        </div>
+               </div>
+       </div>
 </div>
-<div class="tab-content">
-       <div class="tab-pane active row" id="info">
-               <div class="col-md-12">
-                       <div id="authority-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Authority" /></div>
-                   <div id="authority-tab-loaded" style="display:none;">
-                       <div id="authority-data"></div>
-                   </div>
-          </div>
+<div class="container">
+       <div class="row">
+               <div class="col-md-12">
+                       <ul class="nav nav-tabs nav-section">
+                               <li class="active"><a href="#about">About</a></li>
+                               <li><a href="#users">Users</a></li>
+                               <li><a href="#slices">Slices</a></li>
+                               <li><a href="#requests">Requests</a></li>
+                       </ul>
+           </div>
        </div>
-
+</div>
+<div class="container tab-content">
+       <div class="tab-pane active row" id="about">
+       </div>
+       
        <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
-               <div class="col-md-12">
+               <div class="col-md-12 el">
                        <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
                                <div id="user-tab-loaded" style="display:none;">
-                               <table id="user-tab">
+                               <table id="user-tab" class="table">
                                        <tr>
                                        <th>+/-</th>
-                                       <th>email</th>
-                                       <th>user_hrn</th>
-                                       <th>first name</th>
-                                       <th>last name</th>
-                                       <th>enabled</th>
+                                       <th>Email</th>
+                                       <th>User hrn</th>
+                            <!--
+                                       <th>First name</th>
+                                       <th>Last name</th>
+                                       <th>Enabled</th>
+                            -->
                                        </tr>
                                </table>
-                               {%if 'is_pi'  in pi %}  
-                               <div>
-                                       <button id="deleteusers" type="button" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span> Delete Users</button>
-                               </div>
-                               {%endif%}
+                               
+                       </div>
+                       {%if 'is_pi'  in pi %}  
+                       <div>
+                               <button id="deleteusers" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected users</button>
                        </div>
+                       {% endif %}
                </div>
        </div>
-       
+
        <div class="tab-pane row" id="slices">
+               <div class="col-md-12 el">
            <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
            <div id="slice-tab-loaded" style="display:none;">
-               {%if 'is_pi'  in pi %}
-               <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> create slice</button>
-               {%else%}
-               <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> request slice</button>
-               {%endif%}
-               <table id="slice-tab">
+               <table id="slice-tab" class="table">
                    <tr>
                        <th>+/-</th>
-                       <th>slice_hrn</th>
-                       <th>users</th>
-                       <th>url</th>
+                       <th>Slice hrn</th>
+                       <th>Users</th>
+                       <th>Url</th>
                        <!-- <th>nodes</th> -->
-                       <th>expiration</th>
+                       <th>Creation</th>
                    </tr>
-               </table>
-               <br>
-                       {%if 'is_pi'  in pi %}
-               <div>
-                   <button id="renewslices" type="button" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
-                   <button id="deleteslices" type="button" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
-               </div>
-                       {%endif%} 
+               </table>                        
            </div>
+       {% if 'is_pi'  in pi %}
+        <div>
+               {% if 'is_pi'  in pi %}
+                       <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
+                       {% else %}
+                       <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
+                       {% endif %}
+            <button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
+            <button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
+        </div>
+               {% endif %} 
+          </div>
+       </div>
+       <div class="tab-pane row" id="requests">
        </div>
 </div>
 <script>
 $(document).ready(function() {
     {% if person %}
     {% if user_details.parent_authority %}
-        
-        $.post("/rest/authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'}}, function( data ) {
-            var authority_data = [];
-            var onelab_data = [];
-                       /* 'city','enabled','legal','longitude','onelab_membership','address','parent_authority','slice','user','country',
-            'tech','abbreviated_name','url','postcode','description','scientific','authority_hrn','latitude','name'    */
-            $.each( data, function( key, val ) {
-                authority_row = "<img src='{{ STATIC_URL }}img/institutions/{{user_details.parent_authority}}.gif' alt='' /><br>";
-                authority_row += "<br>";
-                authority_row += "<b>authority:</b> "+val.authority_hrn+"<br>";
-                authority_data.push(authority_row);
-            });
-            $("div#authority-data").html(authority_data.join( "" ));
-            $("div#onelab-data").html(onelab_data.join( "" ));
-            $("div#authority-tab-loaded").css("display","block");
-            $("div#authority-tab-loading").css("display","none");
-         });
 
-        $.post("/rest/myslice:slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
+        $.post("/rest/myslice:slice/",{'fields':['slice_hrn','users','url','slice_date_created'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
             var list_slices = [];
             var table_slices = [];
             /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */
@@ -108,16 +103,17 @@ $(document).ready(function() {
                 }else{
                     nodes_length=val.nodes.length;
                 }
+                console.log(val);
                 if(val.users=="undefined" || val.users==null){
                     users_length=0;
                 }else{
                     users_length=val.users.length;
                 }
 
-                if(val.slice_url=="undefined" || val.slice_url==null){
+                if(val.url=="undefined" || val.url==null){
                     slice_url="";
                 }else{
-                    slice_url="<a href='"+val.slice_url+"' target='_blank'>"+val.slice_url+"</a>";
+                    slice_url="<a href='"+val.url+"' target='_blank'>"+val.url+"</a>";
                 }
                 
                 slice_row = "<tr id='"+val.slice_hrn+"'>";
@@ -126,7 +122,7 @@ $(document).ready(function() {
                 slice_row += "<td>"+users_length+"</td>";
                 slice_row += "<td>"+slice_url+"</td>";
                 //slice_row += "<td>"+nodes_length+"</td>";
-                slice_row += "<td>"+val.slice_expires+"</td>";
+                slice_row += "<td>"+val.slice_date_created+"</td>";
                 slice_row += "</tr>";
                 table_slices.push(slice_row);
                 
@@ -137,34 +133,75 @@ $(document).ready(function() {
             $("div#slice-tab-loaded").css("display","block");
             $("div#slice-tab-loading").css("display","none");
         });
+               
+        {% if project %}
+        // XXX LOIC CACHE PB IF PREFIXED !
+               $.post("/rest/authority/",{'fields':['pi_users'],'filters':{'authority_hrn':'{{user_details.parent_authority}}'}}, function( data ) {
+           
+            var table_users = [];
+            $.each( data[0].pi_users, function( key, val ) {
+                console.log(val);
+                user_row = "<tr id='"+val+"'>";
+                user_row += "<td><input type='checkbox' class='user' id='"+val+"'></td>";
+                user_row += "<td></td>";
+                user_row += "<td>"+val+"</td>";
+                user_row += "</tr>";
+                table_users.push(user_row);
+            });
+            $("table#user-tab tr:last").after(table_users.join( "" ));
+            $("div#user-tab-loaded").css("display","block");
+            $("div#user-tab-loading").css("display","none");
 
-               $.post("/rest/user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
-             var list_users = [];
-             var table_users = [];
-                        /* Available fields
-                        user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
-                        user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
-                        */
-             $.each( data, function( key, val ) {
-                 list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
-                 user_row = "<tr id='"+val.user_hrn+"'>";
-                 user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
-                 user_row += "<td>"+val.user_email+"</td>";
-                 user_row += "<td>"+val.user_hrn+"</td>";
-                 user_row += "<td>"+val.user_first_name+"</td>";
-                 user_row += "<td>"+val.user_last_name+"</td>";
-                                user_row += "<td>"+val.user_enabled+"</td>";
-                 user_row += "</tr>";
-                 table_users.push(user_row);
-             });
-             $("table#user-tab tr:last").after(table_users.join( "" ));
-             $("div#user-tab-loaded").css("display","block");
-             $("div#user-tab-loading").css("display","none");
-          });
+        });
+        {% else %}
+        $.post("/rest/user/",{'fields':['user_hrn','user_email'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
+            var list_users = [];
+            var table_users = [];
+                   /* Available fields
+                   user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
+                   user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
+                   */
+            $.each( data, function( key, val ) {
+                list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
+                user_row = "<tr id='"+val.user_hrn+"'>";
+                user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
+                user_row += "<td>"+val.user_email+"</td>";
+                user_row += "<td>"+val.user_hrn+"</td>";
+                /*
+                user_row += "<td>"+val.user_first_name+"</td>";
+                user_row += "<td>"+val.user_last_name+"</td>";
+                           user_row += "<td>"+val.user_enabled+"</td>";
+                */
+                user_row += "</tr>";
+                table_users.push(user_row);
+            });
+            $("table#user-tab tr:last").after(table_users.join( "" ));
+            $("div#user-tab-loaded").css("display","block");
+            $("div#user-tab-loading").css("display","none");
+        });
+
+        {% endif %}
+    {% endif %}
+    {% endif %}
 
-   {% endif %}
-   {% endif %}
+}); // End document.ready
 
-}); // end document.ready
+$(document).ready(function() {
+       $('.nav-tabs a').click(function (e) {
+               e.preventDefault();
+               $(this).tab('show');
+       var id = $(this).attr('href').substr(1);
+        /*
+       if ((id == 'requests') || (id == 'about'))
+               $("#" + id).load('/management/' + id);
+        */
+       });
+       var hash = window.location.hash;
+       if (hash) {
+               $('.nav-tabs a[href='+hash+']').click();
+       } else {
+               $('.nav-tabs a[href=#about]').click();
+       }
+});
 </script>
 {% endblock %}
diff --git a/portal/templates/onelab/onelab_institution.html b/portal/templates/onelab/onelab_institution.html
deleted file mode 100644 (file)
index 4dcaf1b..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-{% extends "layout_wide.html" %}
-
-{% block head %} 
-<script type="text/javascript" src="{{STATIC_URL}}/js/institution.js"></script>
-{% endblock head %}
-
-{% block content %}
-<div class="container">
-       <div class="row">
-               <div class="col-md-12">
-                        <div class="breadcrumbs">
-                                Management &nbsp;>&nbsp; Institution: <span id="authority_name"></span>
-                        </div>
-               </div>
-       </div>
-</div>
-<div class="container">
-       <div class="row">
-               <div class="col-md-12">
-                       <ul class="nav nav-tabs nav-section">
-                               <li class="active"><a href="#about">About</a></li>
-                               <li><a href="#users">Users</a></li>
-                               <li><a href="#slices">Slices</a></li>
-                               <li><a href="#requests">Requests</a></li>
-                       </ul>
-           </div>
-       </div>
-</div>
-<div class="container tab-content">
-       <div class="tab-pane active row" id="about">
-       </div>
-       
-       <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
-               <div class="col-md-12 el">
-                       <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
-                               <div id="user-tab-loaded" style="display:none;">
-                               <table id="user-tab" class="table">
-                                       <tr>
-                                       <th>+/-</th>
-                                       <th>Email</th>
-                                       <th>User hrn</th>
-                            <!--
-                                       <th>First name</th>
-                                       <th>Last name</th>
-                                       <th>Enabled</th>
-                            -->
-                                       </tr>
-                               </table>
-                               
-                       </div>
-                       {%if 'is_pi'  in pi %}  
-                       <div>
-                               <button id="deleteusers" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected users</button>
-                       </div>
-                       {% endif %}
-               </div>
-       </div>
-
-       <div class="tab-pane row" id="slices">
-               <div class="col-md-12 el">
-           <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
-           <div id="slice-tab-loaded" style="display:none;">
-               <table id="slice-tab" class="table">
-                   <tr>
-                       <th>+/-</th>
-                       <th>Slice hrn</th>
-                       <th>Users</th>
-                       <th>Url</th>
-                       <!-- <th>nodes</th> -->
-                       <th>Creation</th>
-                   </tr>
-               </table>                        
-           </div>
-       {% if 'is_pi'  in pi %}
-        <div>
-               {% if 'is_pi'  in pi %}
-                       <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
-                       {% else %}
-                       <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
-                       {% endif %}
-            <button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
-            <button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
-        </div>
-               {% endif %} 
-          </div>
-       </div>
-       <div class="tab-pane row" id="requests">
-       </div>
-</div>
-<script>
-$(document).ready(function() {
-    {% if person %}
-    {% if user_details.parent_authority %}
-
-        $.post("/rest/slice/",{'fields':['slice_hrn','users','url','slice_date_created'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
-            var list_slices = [];
-            var table_slices = [];
-            /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */
-            $.each( data, function( key, val ) {
-                list_slices.push( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
-                if(val.nodes=="undefined" || val.nodes==null){
-                    nodes_length=0;
-                }else{
-                    nodes_length=val.nodes.length;
-                }
-                if(val.users=="undefined" || val.users==null){
-                    users_length=0;
-                }else{
-                    users_length=val.users.length;
-                }
-
-                if(val.url=="undefined" || val.url==null){
-                    slice_url="";
-                }else{
-                    slice_url="<a href='"+val.url+"' target='_blank'>"+val.url+"</a>";
-                }
-                
-                slice_row = "<tr id='"+val.slice_hrn+"'>";
-                slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'></td>";
-                slice_row += "<td><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>";
-                slice_row += "<td>"+users_length+"</td>";
-                slice_row += "<td>"+slice_url+"</td>";
-                //slice_row += "<td>"+nodes_length+"</td>";
-                slice_row += "<td>"+val.slice_date_created+"</td>";
-                slice_row += "</tr>";
-                table_slices.push(slice_row);
-                
-            });
-           
-            /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
-            $("table#slice-tab tr:last").after(table_slices.join( "" ));
-            $("div#slice-tab-loaded").css("display","block");
-            $("div#slice-tab-loading").css("display","none");
-        });
-               
-               
-        $.post("/rest/user/",{'fields':['user_hrn','user_email'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
-            var list_users = [];
-            var table_users = [];
-                   /* Available fields
-                   user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
-                   user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
-                   */
-            $.each( data, function( key, val ) {
-                list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
-                user_row = "<tr id='"+val.user_hrn+"'>";
-                user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
-                user_row += "<td>"+val.user_email+"</td>";
-                user_row += "<td>"+val.user_hrn+"</td>";
-                /*
-                user_row += "<td>"+val.user_first_name+"</td>";
-                user_row += "<td>"+val.user_last_name+"</td>";
-                           user_row += "<td>"+val.user_enabled+"</td>";
-                */
-                user_row += "</tr>";
-                table_users.push(user_row);
-            });
-            $("table#user-tab tr:last").after(table_users.join( "" ));
-            $("div#user-tab-loaded").css("display","block");
-            $("div#user-tab-loading").css("display","none");
-        });
-
-    {% endif %}
-    {% endif %}
-
-}); // End document.ready
-
-$(document).ready(function() {
-       $('.nav-tabs a').click(function (e) {
-               e.preventDefault();
-               $(this).tab('show');
-       var id = $(this).attr('href').substr(1);
-       if ((id == 'requests') || (id == 'about'))
-               $("#" + id).load('/management/' + id);
-       });
-       var hash = window.location.hash;
-       if (hash) {
-               $('.nav-tabs a[href='+hash+']').click();
-       } else {
-               $('.nav-tabs a[href=#about]').click();
-       }
-});
-</script>
-{% endblock %}
index 42a8dcb..905858c 100644 (file)
@@ -37,6 +37,7 @@ from portal.dashboardview           import DashboardView
 from portal.accountview             import AccountView, account_process
 from portal.contactview             import ContactView
 from portal.slicerequestview        import SliceRequestView
+from portal.projectrequestview      import ProjectRequestView
 from portal.registrationview        import RegistrationView
 from portal.joinview                import JoinView
 from portal.sliceviewold            import SliceView
@@ -79,6 +80,7 @@ urlpatterns = patterns('',
     #url(r'^my_account/?$', MyAccountView.as_view(), name='my_account'),
     url(r'^account/?$', AccountView.as_view(), name='account'),
     url(r'^institution/?$', InstitutionView.as_view(), name='institution'),
+    url(r'^project/(?P<authority_hrn>[\w\.]+)/?$', InstitutionView.as_view(), name='project'),
     url(r'^about/?$', AboutView.as_view(), name='about'),
     url(r'^users/?$', UsersView.as_view(), name='user_list'),
     url(r'^user/(?P<email>[\w\s.@\-]+)/?$', UserView.as_view(), name='user'),
@@ -98,6 +100,8 @@ urlpatterns = patterns('',
     #url(r'^pass_reset/?$', PassResetView.as_view(), name='pass_rest'),
     # Slice request
     url(r'^slice_request/?$', SliceRequestView.as_view(), name='slice_request'),
+    # Project request
+    url(r'^project_request/?$', ProjectRequestView.as_view(), name='project_request'),
     url(r'^terms/?$', TermsView.as_view(), name='terms'),
     url(r'^manual_delegation/?$', ManualDelegationView.as_view(), name='manual_delegation'),
     # Validate pending requests
index a856596..96b901f 100644 (file)
@@ -74,6 +74,7 @@ class ObjectRequest(object):
     def setKey(self):
         # What about key formed of multiple fields???
         query = Query.get('local:object').filter_by('table', '==', self.type).select('key')
+        print query
         results = execute_query(self.request, query)
         print "key of object = %s" % results
         if results :
@@ -114,6 +115,8 @@ class ObjectRequest(object):
                     query.filter_by(k, '<=', f[2:])
                 elif (f[:1] == "<") :
                     query.filter_by(k, '<', f[1:])
+                elif (f[:8] == "CONTAINS") :
+                    query.filter_by(k, 'CONTAINS', f[8:])
                 else :
                     query.filter_by(k, '==', f)
         return query