Manage Institution page: improved display and quick loading using explicit fields...
authorLoic Baron <loic.baron@lip6.fr>
Mon, 1 Sep 2014 16:58:12 +0000 (18:58 +0200)
committerLoic Baron <loic.baron@lip6.fr>
Mon, 1 Sep 2014 16:58:12 +0000 (18:58 +0200)
portal/managementtababout.py
portal/templates/onelab/onelab_institution.html
portal/templates/onelab/onelab_management-tab-about.html

index cee9311..8bd1cdc 100644 (file)
@@ -28,8 +28,9 @@ class ManagementAboutView (FreeAccessView, ThemeView):
             user_local_query  = Query().get('local:user').select('config').filter_by('email','==',str(self.request.user))
             user_local_details = execute_query(self.request, user_local_query)
             user_authority = json.loads(user_local_details[0]['config']).get('authority')
-            
-            authority_query = Query().get('authority').select('description', 'authority_hrn', 'legal', 'address', 'abbreviated_name', 
+            # XXX Should be done using Metadata
+            # select column.name from local:object where table=='authority'
+            authority_query = Query().get('authority').select('authority_hrn', 'name', 'address', 'enabled','description', 
                                                               'scientific', 'city', 'name', 'url', 'country', 'enabled', 'longitude', 
                                                               'tech', 'latitude', 'pi_users', 'parent_authority', 'onelab_membership', 
                                                               'postcode').filter_by('authority_hrn','==',user_authority)
@@ -37,11 +38,13 @@ class ManagementAboutView (FreeAccessView, ThemeView):
             
             if authority_details :
                 authority_contacts = {}
-                authority_contacts['scientific'] = [ x.strip()[1:-1] for x in authority_details[0]['scientific'][1:-1].split(',') ]
-                authority_contacts['technical'] = [ x.strip()[1:-1] for x in authority_details[0]['tech'][1:-1].split(',') ]
-            
-                authority_contacts['legal'] = [ x.strip().replace('"','') for x in authority_details[0]['legal'][1:-1].split(',') ]
                 authority = authority_details[0]
+                if 'scientific' in authority and authority['scientific'] is not None:
+                    authority_contacts['scientific'] = [ x.strip()[1:-1] for x in authority['scientific'][1:-1].split(',') ]
+                if 'technical' in authority and authority['technical'] is not None:
+                    authority_contacts['technical'] = [ x.strip()[1:-1] for x in authority['tech'][1:-1].split(',') ]
+                if 'legal' in authority and authority['legal'] is not None:
+                    authority_contacts['legal'] = [ x.strip().replace('"','') for x in authority['legal'][1:-1].split(',') ]
             else :
                 authority_contacts = None
                 authority = None
index c8a668f..bd361de 100644 (file)
                                        <th>+/-</th>
                                        <th>Email</th>
                                        <th>User hrn</th>
+                            <!--
                                        <th>First name</th>
                                        <th>Last name</th>
                                        <th>Enabled</th>
+                            -->
                                        </tr>
                                </table>
                                
@@ -65,7 +67,7 @@
                        <th>Users</th>
                        <th>Url</th>
                        <!-- <th>nodes</th> -->
-                       <th>Expiration</th>
+                       <th>Creation</th>
                    </tr>
                </table>                        
            </div>
@@ -90,7 +92,7 @@ $(document).ready(function() {
     {% if person %}
     {% if user_details.parent_authority %}
 
-        $.post("/rest/slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
+        $.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" */
@@ -108,10 +110,10 @@ $(document).ready(function() {
                     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+"'>";
@@ -120,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);
                 
@@ -133,7 +135,7 @@ $(document).ready(function() {
         });
                
                
-        $.post("/rest/user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
+        $.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
@@ -146,9 +148,11 @@ $(document).ready(function() {
                 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);
             });
index 687b7de..bc768a6 100644 (file)
@@ -4,19 +4,36 @@
                <img src="{{ STATIC_URL|add:'img/institutions/'|add:authority.authority_hrn|add:'.gif'|file_exists }}" alt="{{authority.name}}">
        </div>
        <br />
+    {% if authority.name and authority.url %}
        <h3><a href="{{authority.url}}">{{authority.name}}</a></h3>
+    {% elif authority.name %}
+       <h3>{{authority.name}}</h3>
+    {% endif %}
        <p>
+    {% if authority.address %}
                {{authority.address}} <br />
-               {{authority.postcode}} {{authority.city}} <br />
+    {% endif %}
+    {% if authority.postcode %}
+               {{authority.postcode}} 
+    {% endif %}
+    {% if authority.address %}
+        {{authority.city}} <br />
+    {% endif %}
+    {% if authority.address %}
                {{authority.country}}
+    {% endif %}
        </p>
        <br />
+
+    {% if authority.address %}
        <h4>Onelab membership</h4> 
        <p>
                {{ authority.onelab_membership }}
        </p>
+    {% endif %}
 </div>
 <div class="col-md-6">
+    {% if authority.legal %}
        <h4>Legal Contact:</h4>
        <p>
        {% for c in authority_contacts.legal %}
@@ -24,6 +41,8 @@
        {% endfor %}
        </p>
        <br />
+    {% endif %}
+    {% if authority.scientific %}
        <h4>Scientific Contact:</h4>
        <p>
        {% for c in authority_contacts.scientific %}
        {% endfor %}
        </p>
        <br />
+    {% endif %}
+    {% if authority.technical %}
        <h4>Technical Contact:</h4>
        <p>
        {% for c in authority_contacts.technical %}
                {{ c }} <br />
        {% endfor %}
        </p>
+    {% endif %}
 </div>
 <script>$(document).ready(function() {
 {% if authority.name %}