Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
authorCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Fri, 25 Jul 2014 10:35:14 +0000 (12:35 +0200)
committerCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Fri, 25 Jul 2014 10:35:14 +0000 (12:35 +0200)
13 files changed:
manifoldapi/static/js/manifold.js
plugins/apply/static/js/apply.js
plugins/apply/templates/apply.html
plugins/googlemap/static/js/googlemap.js
plugins/scheduler2/static/css/scheduler2.css
plugins/scheduler2/templates/scheduler.html
plugins/testbeds/templates/testbeds.html
portal/accountview.py
portal/actions.py
portal/homeview.py
portal/joinview.py
portal/registrationview.py
portal/slicerequestview.py

index e0454a5..00e5562 100644 (file)
@@ -757,6 +757,9 @@ var manifold = {
 
     _record_equals: function(self, other, key_fields)
     {
+        if ((typeof self === "string") && (typeof other === "string")) {
+            return self == other;
+        }
         for (var i=0; i < key_fields.length; i++) {
             var this_value  = self[key_fields[i]];
             var other_value = other[key_fields[i]];
index 1973028..b94fcd6 100644 (file)
                        bAutoWidth: true,
             });
             
-            //this.elmt('update').click(this, this.do_ok);
-            //this.elmt('refresh').click(this, this.do_cancel);
+            this.elmt('close').click(this, this.do_close);
+            //this.elmt('apply_cancel').click(this, this.do_cancel);
 
-            this.elmt('apply').on('shown.bs.modal', function() {
+            this.elmt('apply__window').on('shown.bs.modal', function() {
                 self.do_update();
             })
 
@@ -80,7 +80,6 @@
 
         clear: function()
         {
-
         },
 
         find_row: function(value)
 
         },
 
-        do_ok: function(e)
+        do_close: function(e)
         {
-            throw 'queryupdater.do_reset Not implemented';
+            var self = e.data;
+            self.table.fnClearTable();
         },
 
+        // Not used today
         do_cancel: function(e)
         {
             throw 'queryupdater.do_clear_annotations Not implemented';
index 6507012..31a22ee 100644 (file)
@@ -1,6 +1,6 @@
 <div id={{ domid }}>
   <!-- Modal - columns selector -->
-  <div class="modal fade" id="{{domid}}__apply" tabindex="-1" role="dialog" aria-labelledby="{{domid}}__apply__label" aria-hidden="true">
+  <div class="modal fade" id="{{domid}}__apply__window" tabindex="-1" role="dialog" aria-labelledby="{{domid}}__apply__label" aria-hidden="true">
     <div class="modal-dialog modal-dialog-large">
       <div class="modal-content">
         <div class="modal-header">
@@ -28,7 +28,7 @@
 -->
         </div>
         <div class="modal-footer">
-          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+          <button id="{{domid}}__close" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
         </div>
       </div>
     </div>
@@ -36,6 +36,6 @@
 
   
   <!-- Button toolbar -->
-  <button class="btn btn-onelab btn-sm" data-toggle="modal" data-target="#{{domid}}__apply">Apply</button>
-  <button class="btn btn-default btn-sm" data-toggle="modal" data-target="#{{domid}}__cancel">Cancel</button>
+  <button class="btn btn-onelab btn-sm"  id="{{domid}}__apply" data-toggle="modal" data-target="#{{domid}}__apply__window">Apply</button>
+  <!-- <button class="btn btn-default btn-sm" id="{{domid}}__cancel">Cancel</button> -->
 </div> 
index 5a15a3d..3d18757 100644 (file)
@@ -173,7 +173,7 @@ GOOGLEMAP_BGCOLOR_REMOVED = 2;
                 data = {
                     state: STATE_SET,
                     key  : null,
-                    op   : this.checked ? SET_ADD : SET_REMOVED,
+                    op   : this.checked ? STATE_SET_ADD : STATE_SET_REMOVE,
                     value: id
                 }
                 manifold.raise_event(self.options.query_uuid, FIELD_STATE_CHANGED, data);
index cda74b1..9d0cda1 100755 (executable)
 }\r
 \r
 #scheduler-reservation-table tbody tr td.free:hover ,#scheduler-reservation-table tbody tr td.selected, #scheduler-reservation-table tbody tr td.selected_tmp {\r
-    background: #25BA25;\r
+    background: #26c9e2;\r
 }\r
 \r
 td.no-image {\r
@@ -269,10 +269,11 @@ td.no-image {
     filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a6c9e2', endColorstr='#e0e0e0',GradientType=1 ); /* IE6-9 */\r
 \r
     padding: 3px 0 3px 30px;\r
-    width: 150px;\r
+    width: 250px;\r
 }\r
 \r
 .legend ol li.free{\r
+       background: #FFFFFF;\r
 \r
 }\r
 .legend ol li.pendingin{\r
@@ -295,6 +296,10 @@ background: #E8E8E8;
     background: #25BA25;\r
 }\r
 \r
+.legend ol li.disabled {\r
+       background: url("../img/forbidden.png") no-repeat scroll 2px 50% #FFFFFF;\r
+}\r
+\r
 /* latest stuff */\r
 .sliderContainer {\r
        margin-left: -15px;\r
index e07637a..7c29877 100755 (executable)
             <div class="legend">\r
                 <ol>\r
                     <li class="free">Free</li>\r
-                    <li class="pendingin">Pending selected</li>\r
-                    <li class="pendingout">Pending deselected</li>\r
-                    <li class="selected">Selected</li>\r
-                    <li class="closed">Reserved</li>\r
+                    <li class="selected">Reserved</li>\r
+                    <li class="pendingin">Reservation pending</li>\r
+                    <li class="pendingout">Reservation cancellation pending</li>\r
+                    <li class="closed">Unavailable</li>\r
+                                       <li class="disabled">Forbidden</li>\r
                     <li class="maintenance">Maintenance</li>\r
                 </ol>\r
             </div>\r
index d670c9d..22f7f0a 100644 (file)
        </a>
 </div>
 
+<style>
+a.sl-platform  {
+    text-transform: uppercase;
+}
+
+</style>
+
 </div>
index c179a0e..fb9f642 100644 (file)
@@ -348,6 +348,8 @@ def account_process(request):
         return HttpResponseRedirect("/portal/account/")
 
 # XXX TODO: Factorize with portal/registrationview.py
+# XXX TODO: Factorize with portal/registrationview.py
+# XXX TODO: Factorize with portal/joinview.py
 
     elif 'generate' in request.POST:
         for account_detail in account_details:
index 3479c02..d62f994 100644 (file)
@@ -321,13 +321,14 @@ def portal_validate_request(wsgi_request, request_ids):
                 # XXX tmp sfa dependency
                 from sfa.util.xrn import Xrn 
                 urn = Xrn(hrn, request['type']).get_urn()
-
+                
+                # Only hrn is required for Manifold Query 
                 sfa_authority_params = {
-                    'hrn'        : hrn,
-                    'urn'        : urn,
-                    'type'       : request['type'],
+                    'authority_hrn'        : hrn,
+                    #'authority_urn'        : urn,
+                    #'type'       : request['type'],
                     #'pi'        : None,
-                    'enabled'    : True
+                    #'enabled'    : True
                 }
                 print "ADD Authority"
                 sfa_add_authority(wsgi_request, sfa_authority_params)
@@ -376,6 +377,8 @@ def create_slice(wsgi_request, request):
     # Add User to Slice if we have the user_hrn in pendingslice table
     user_hrn = request.get('user_hrn', None)
     user_hrns = list([user_hrn]) if user_hrn else list()
+    
+    user_email = request.get
 
     # XXX We should create a slice with Manifold terminology
     slice_params = {
@@ -391,6 +394,13 @@ def create_slice(wsgi_request, request):
     results = execute_query(wsgi_request, query)
     if not results:
         raise Exception, "Could not create %s. Already exists ?" % slice_params['hrn']
+    ## We do not store the email in pendingslice table. As a result receiver's email is unknown ##
+    ## Need modification in pendingslice table ###
+    #else:
+    #    subject = 'Slice created'
+    #    msg = 'A manager of your institution has validated your slice request. You can now add resources to the slice and start experimenting.'
+    #    send_mail(subject, msg, 'support@onelab.eu',['yasin.upmc@gmail.com'], fail_silently=False)
+       
     return results
 
 def create_pending_slice(wsgi_request, request, email):
@@ -505,6 +515,10 @@ def sfa_create_user(wsgi_request, request):
     results = execute_query(wsgi_request, query)
     if not results:
         raise Exception, "Could not create %s. Already exists ?" % sfa_user_params['user_hrn']
+    else:
+        subject = 'User validated'
+        msg = 'A manager of your institution has validated your account. You have now full user access to the portal.'
+        send_mail(subject, msg, 'support@onelab.eu',[request['email']], fail_silently=False)       
     return results
 
 def create_user(wsgi_request, request):
index 4576431..ae45ee1 100644 (file)
@@ -106,11 +106,12 @@ class HomeView (FreeAccessView, ThemeView):
             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')
+                    if 'platform_id' in platform_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=={} or acc_auth_cred=='N/A':
                 pi = "is_not_pi"
index 8356dec..f9eed28 100644 (file)
@@ -74,6 +74,8 @@ class JoinView (FreeAccessView, ThemeView):
             #prepare user_hrn 
             split_email = reg_email.split("@")[0] 
             split_email = split_email.replace(".", "_")
+            # Replace + by _ => more convenient for testing and validate with a real email
+            split_email = split_email.replace("+", "_")
             user_hrn = reg_auth + '.' + split_email
             
             UserModel = get_user_model()
@@ -108,18 +110,15 @@ class JoinView (FreeAccessView, ThemeView):
                     errors.append('Email already registered in Manifold. Please provide a new email address.')
 
 # XXX TODO: Factorize with portal/accountview.py
+# XXX TODO: Factorize with portal/registrationview.py
+# XXX TODO: Factorize with portal/joinview.py
 #            if 'generate' in request.POST['question']:
             from Crypto.PublicKey import RSA
             private = RSA.generate(1024)
-            private_key = json.dumps(private.exportKey())
-            public  = private.publickey()
-            public_key = json.dumps(public.exportKey(format='OpenSSH'))
-
+            private_key = private.exportKey()
+            public_key = private.publickey().exportKey(format='OpenSSH')
             # Saving to DB
-            account_config = '{"user_public_key":'+ public_key + ', "user_private_key":'+ private_key + ', "user_hrn":"'+ user_hrn + '"}'
             auth_type = 'managed'
-            public_key = public_key.replace('"', '');
-            private_key = private_key.replace('"', '');
 
             if not errors:
                 reg_password = request.POST['pi_password']
index b996e95..e0a1ddf 100644 (file)
@@ -85,6 +85,8 @@ class RegistrationView (FreeAccessView, ThemeView):
             # Construct user_hrn from email (XXX Should use common code)
             split_email = user_request['email'].split("@")[0] 
             split_email = split_email.replace(".", "_")
+            # Replace + by _ => more convenient for testing and validate with a real email
+            split_email = split_email.replace("+", "_")
             user_request['user_hrn'] = user_request['authority_hrn'] \
                      + '.' + split_email
             
@@ -120,6 +122,8 @@ class RegistrationView (FreeAccessView, ThemeView):
                             + '.' + split_email + str(randint(1,1000000))
                 
             # XXX TODO: Factorize with portal/accountview.py
+            # XXX TODO: Factorize with portal/registrationview.py
+            # XXX TODO: Factorize with portal/joinview.py
             if 'generate' in wsgi_request.POST['question']:
                 user_request['auth_type'] = 'managed'
 
index 598aca3..95d2794 100644 (file)
@@ -35,6 +35,7 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
         purpose=''
         exp_url=''
         authority_hrn = None
+        authority_name = None
         # Retrieve the list of authorities
         authorities_query = Query.get('authority').select('name', 'authority_hrn')
         authorities = execute_admin_query(wsgi_request, authorities_query)
@@ -54,6 +55,9 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
             if authority['authority_hrn'] == user_authority:
                 authority_name = authority['name']
 
+        # Handle the case when we use only hrn and not name
+        if authority_name is None:
+            authority_name = user_authority
         #
         account_query  = Query().get('local:account').select('user_id','platform_id','auth_type','config')
         account_details = execute_query(wsgi_request, account_query)
@@ -98,7 +102,7 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
                 if authority['name'] == wsgi_request.POST.get('org_name', ''):
                     authority_hrn = authority['authority_hrn']
 
-            # Handle the case when the template uses only hrn and not name
+            # Handle the case when we use only hrn and not name
             if authority_hrn is None:
                 authority_hrn = wsgi_request.POST.get('org_name', '')