Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
authorYasin <mohammed-yasin.rahman@lip6.fr>
Fri, 28 Feb 2014 15:22:25 +0000 (16:22 +0100)
committerYasin <mohammed-yasin.rahman@lip6.fr>
Fri, 28 Feb 2014 15:22:25 +0000 (16:22 +0100)
portal/templates/institution.html
portal/templates/onelab/onelab_widget-slice-sections.html
rest/update.py [new file with mode: 0644]

index 575a1f0..d8fb1d7 100644 (file)
@@ -2,28 +2,25 @@
 
 {% block content %}
 <div class="row">
-       <h1><img src="{{ STATIC_URL }}img/icon_authority_color_small.png" alt="" /> Affiliation to an Institution</h1>
+       <h1><img src="{{ STATIC_URL }}img/icon_authority_color_small.png" alt="" /> Institution: {{user_details.parent_authority}}</h1>
 </div>
 <div class="row" id="institution">
     <ul class="nav nav-tabs">
-      <li class="active" id="authority-tab"><a class="home-tab" data-panel="institution" href="#">INSTITUTION</a></li>
+      <li class="active" id="authority-tab"><a class="home-tab" data-panel="institution" href="#">INFO</a></li>
       <li id="users-tab"><a class="home-tab" data-panel="users" href="#">USERS</a></li>
       <li id="slices-tab"><a class="home-tab" data-panel="slices" href="#">SLICES</a></li>
     </ul>
     <div class="home-panel" id="institution">
         <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="onelab_membership" style="float:left; width:30%;">
+            <div id="authority-data" style="float:left; width:50%;"></div>
+            <div id="onelab_membership" style="float:right; width:50%;">
                 <img src="{{ STATIC_URL }}img/onelab-logo.png" alt="" /><br>
                 <div id="onelab-data"></div>
             </div>
-            <div id="authority-data" style="float:right; width:70%;">
-            </div>
         </div>
     </div>
     <div class="home-panel" id="users" style="display:none;">
-               <br>
-        <h1>Users: {{user_details.parent_authority}}</button></h1>
         <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">
@@ -41,8 +38,6 @@
         </div>
        </div>
     <div class="home-panel" id="slices" style="display:none;">
-        <br>
-        <h1>Slices: {{user_details.parent_authority}} <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create a Slice</button></h1>
         <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">
                 */
                     authority_row += val.scientific+"<br>";
                 //}
-                onelab_membership = "<b>Membership:</b> "+val.onelab_membership;
+                onelab_membership = "<b>Status: </b>"+val.onelab_membership;
                 onelab_data.push(onelab_membership);
                 authority_data.push(authority_row);
             });
index d01bdbe..e637b15 100644 (file)
@@ -3,7 +3,7 @@
                <li {% if section == 'slice' %}class="active"{% endif %}><a href="/slice/{{ slice }}/">{{ slice }}</a></li>
                <li {% if section == 'testbeds' %}class="active"{% endif %}><a href="/testbeds/{{ slice }}/">Testbeds</a></li>
                <li {% if section == 'resources' %}class="active"{% endif %}><a href="/resources/{{ slice }}/">Resources</a></li>
-               <li {% if section == 'users' %}class="active">{% endif %}><a href="/users/{{ slice }}/">Users</a></li>
+               <li {% if section == 'users' %}class="active"{% endif %}><a href="/users/{{ slice }}/">Users</a></li>
                <li><a href="">Statistics</a></li>
                <li><a href="">Measurements</a></li>
        </ul>
diff --git a/rest/update.py b/rest/update.py
new file mode 100644 (file)
index 0000000..953e786
--- /dev/null
@@ -0,0 +1,67 @@
+from manifold.core.query            import Query
+
+from django.views.generic.base      import TemplateView
+from django.shortcuts               import render_to_response
+
+from unfold.loginrequired           import LoginRequiredView
+from django.http                    import HttpResponse
+
+from manifold.core.query            import Query, AnalyzedQuery
+from manifoldapi.manifoldapi        import execute_query
+
+from string import join
+import decimal
+import datetime
+import json
+
+# handles serialization of datetime in json
+DateEncoder = lambda obj: obj.strftime("%B %d, %Y %H:%M:%S") if isinstance(obj, datetime.datetime) else None
+
+# support converting decimal in json
+json.encoder.FLOAT_REPR = lambda o: format(o, '.2f')
+
+# handles decimal numbers serialization in json
+class DecimalEncoder(json.JSONEncoder):
+    def _iterencode(self, o, markers=None):
+        if isinstance(o, decimal.Decimal):
+            return (str(o) for o in [o])
+        return super(DecimalEncoder, self)._iterencode(o, markers)
+
+def dispatch(request, object_type, object_name):
+    
+    object_filters = {}
+    object_params = {}
+    result = {}
+    
+    if request.method == 'POST':
+        req_items = request.POST.items()
+    elif request.method == 'GET':
+        return HttpResponse(json.dumps({'error' : 'only post request is supported'}), content_type="application/json")
+
+    query = Query.update(object_type)
+    
+    if object_filters :
+        for k, f in object_filters.iteritems() :
+            query.filter_by(k, '==', f)
+    
+    # DEBUG        
+    print object_filters
+    
+    if object_params :
+        query.set(object_params.iteritems())
+    else :
+        return HttpResponse(json.dumps({'error' : 'an error has occurred'}), content_type="application/json")
+    
+    # DEBUG
+    print object_params
+    
+    #result = execute_query(request, query)
+    
+    # DEBUG
+    print result
+    
+    if result :
+        return HttpResponse(json.dumps({'error' : 'an error has occurred'}), content_type="application/json")
+    else :
+        return HttpResponse(json.dumps({'success' : 'record updated'}), content_type="application/json")
+    
\ No newline at end of file