updates for onelab portal demo
authorJordan Augé <jordan.auge@lip6.fr>
Mon, 29 Jul 2013 03:42:37 +0000 (05:42 +0200)
committerJordan Augé <jordan.auge@lip6.fr>
Mon, 29 Jul 2013 03:42:37 +0000 (05:42 +0200)
auth/manifoldbackend.py
manifold/core/result_value.py
manifold/manifoldapi.py
manifold/manifoldproxy.py
myslice/viewutils.py
plugins/googlemap/googlemap.js
plugins/tabs/tabs.py
portal/views.py
trash/sliceview.py

index c58c09e..f763291 100644 (file)
@@ -39,7 +39,8 @@ class ManifoldBackend:
             print "ok"
             if not sessions:
                 print "GetSession failed", sessions_result.error()
-            print "first"
+                return
+            print "first", sessions
             session = sessions[0]
             print "SESSION=", session
 
@@ -60,6 +61,8 @@ class ManifoldBackend:
             request.session['manifold'] = {'auth': api.auth, 'person': person, 'expires': session['expires']}
         except Exception, e:
             print "E: manifoldbackend", e
+            import traceback
+            traceback.print_exc()
             return None
 
         try:
index 7728e8a..4fe505f 100644 (file)
@@ -48,10 +48,8 @@ class ResultValue(dict):
 
     def __init__(self, **kwargs):
         
-        print "KWARGS=", kwargs
         # Checks
         given = set(kwargs.keys())
-        print "given=", given
         cstr_success = set(['code', 'origin', 'value']) <= given
         cstr_error   = set(['code', 'type', 'origin', 'description']) <= given
         assert given <= self.ALLOWED_FIELDS, "Wrong fields in ResultValue constructor: %r" % (given - self.ALLOWED_FIELDS)
@@ -95,6 +93,9 @@ class ResultValue(dict):
     def ok_value(self):
         return self['value']
 
+    def error(self):
+        err = "%r" % self['description']
+
     @staticmethod
     def to_html (raw_dict):
         return pprint.pformat (raw_dict).replace("\\n","<br/>")
index eaf9266..9361b6e 100644 (file)
@@ -52,6 +52,10 @@ class ManifoldAPI:
                 return ResultValue(**result)
 
             except Exception,error:
+                # XXX Connection refused for example
+                print "** API ERROR **"
+                import traceback
+                traceback.print_exc()
                 if debug: print "KO (unexpected exception)",error
                 raise ManifoldException ( ManifoldResult (code=ManifoldCode.UNKNOWN_ERROR, output="%s"%error) )
 
index 9d322ca..f6ceb0e 100644 (file)
@@ -90,7 +90,8 @@ with the query passed using POST"""
         result = manifold_api.forward(manifold_query.to_dict())
 
         # XXX TEMP HACK
-        result [ 'description' ] = [ ResultValue.to_html (x) for x in result['description'] ]
+        if 'description' in result and result['description'] and isinstance(result['description'], (tuple, list, set, frozenset)):
+            result [ 'description' ] = [ ResultValue.to_html (x) for x in result['description'] ]
 
         json_answer=json.dumps(result)
         # if in debug mode we save this so we can use offline mode later
@@ -107,6 +108,7 @@ with the query passed using POST"""
         return HttpResponse (json_answer, mimetype="application/json")
 
     except:
+        print "** PROXY ERROR **"
         import traceback
         traceback.print_exc()
 
index 937fa9b..a5f89f5 100644 (file)
@@ -15,10 +15,14 @@ standard_topmenu_items = [
 
 def topmenu_items (current,request=None):
     result=deepcopy(standard_topmenu_items)
+    has_user=request.user.is_authenticated()
+    if has_user:
+        result.append({ 'label':'Request a slice', 'href': '/portal/slice/request/'})
     for d in result:
-        if d['label'].lower().find(current)>=0: d['is_active']=True
+        #if d['label'].lower()find(current)>=0: d['is_active']=True
+        if d['label'] == current: d['is_active']=True
+        print "CURRENT=", current
     if not request: return result
-    has_user=request.user.is_authenticated()
 #    result.append (login_out_items [ has_user] )
     return result
 
index 62e1d6f..2b0b88a 100644 (file)
                 GoogleMap : GoogleMap
             });
 
+            /* Events */
+            $this.on('show.GoogleMaps', methods.show);
+
+
             /* Subscribe to query updates */
             jQuery.subscribe('/results/' + options.query_uuid + '/changed', {instance: $this}, update_map);
             jQuery.subscribe('/update-set/' + options.query_uuid, {instance: $this}, on_resource_changed);
index 0350c26..6da94da 100644 (file)
@@ -3,7 +3,7 @@ from unfold.composite import Composite
 class Tabs (Composite):
     
     def requirements (self):
-        return { 'js_files'     : 'js/bootstrap.js',
+        return { 'js_files'     : ['js/tabs.js', 'js/bootstrap.js'],
                  'css_files'    : ['css/bootstrap.css', 'css/tabs.css', ] 
                  }
 
@@ -12,3 +12,8 @@ class Tabs (Composite):
 
     # see Composite.py for the details of template_env, that exposes global
     # 'sons' as a list of sons with each a set of a few attributes
+    def json_settings_list (self):
+        return []
+
+    def export_json_settings(self):
+        return True
index dd63182..f27b178 100644 (file)
@@ -46,7 +46,7 @@ class DashboardView(TemplateView):
 
         # Slow...
         #slice_query = Query().get('slice').filter_by('user.user_hrn', 'contains', user_hrn).select('slice_hrn')
-        slice_query = Query().get('user').filter_by('user_hrn', '==', user_hrn).select('slice.slice_hrn')
+        slice_query = Query().get('user').filter_by('user_hrn', '==', user_hrn).select('user_hrn', 'slice.slice_hrn')
         auth_query  = Query().get('network').select('network_hrn')
         page.enqueue_query(slice_query)
         page.enqueue_query(auth_query)
@@ -76,7 +76,7 @@ class DashboardView(TemplateView):
         # more general variables expected in the template
         context['title'] = 'Test view that combines various plugins'
         # the menu items on the top
-        context['topmenu_items'] = topmenu_items('dashboard', self.request) 
+        context['topmenu_items'] = topmenu_items('Dashboard', self.request) 
         # so we can sho who is logged
         context['username'] = the_user(self.request) 
 
index 252291f..b171487 100644 (file)
@@ -66,7 +66,7 @@ def _slice_view (request, slicename):
         main_query.select(
                 'slice_hrn',
                 'resource.resource_hrn', 'resource.hostname', 'resource.type', 'resource.authority',
-                'lease.urn',
+                #'lease.urn',
                 'user.user_hrn',
 #                'application.measurement_point.counter'
         )
@@ -371,7 +371,7 @@ def _slice_view (request, slicename):
     # more general variables expected in the template
     template_env [ 'title' ] = 'Test view that combines various plugins'
     # the menu items on the top
-    template_env [ 'topmenu_items' ] = topmenu_items('slice', request) 
+    template_env [ 'topmenu_items' ] = topmenu_items('Slice', request) 
     # so we can sho who is logged
     template_env [ 'username' ] = the_user (request)