Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into fibre
authorLoic Baron <loic.baron@lip6.fr>
Fri, 25 Jul 2014 18:22:38 +0000 (15:22 -0300)
committerLoic Baron <loic.baron@lip6.fr>
Fri, 25 Jul 2014 18:22:38 +0000 (15:22 -0300)
Conflicts:
portal/homeview.py

17 files changed:
manifoldapi/static/js/manifold.js
manifoldapi/static/js/plugin.js
myslice/urls.py
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
portal/accountview.py
portal/actions.py
portal/homeview.py
portal/joinview.py
portal/manageuserview.py
portal/slicerequestview.py
portal/templates/base.html
portal/templates/slice-tab-users-view.html
rest/credentials.py [new file with mode: 0644]

index e0cf338..30cb75e 100644 (file)
@@ -758,6 +758,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 324c8c4..495bdc7 100644 (file)
@@ -318,7 +318,7 @@ var Plugin = Class.extend({
     // you can also call spin_presets() yourself and tweak what you need to, like topmenuvalidation does
     spin: function (message) {
        if (!message) {
-               message = 'Please be patient, this can take a few seconds.';
+               message = 'Please be patient, this can take a minute or two.';
        }
        $('div.loading').fadeIn('fast');
        $('div.loading').find('.message').text(message);
index 07db378..b318cb0 100644 (file)
@@ -82,7 +82,10 @@ urls = [
     (r'^update/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.update.dispatch'),
     (r'^create/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.create.dispatch'),
     (r'^delete/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.delete.dispatch'),
+    (r'^credentials/(?P<action>[^/]+)/?$', 'rest.credentials.dispatch'),
     #
+    # REST monitoring
+    #(r'^monitor/sfa/getversion/?$', 'rest.monitor.sfaGetVersion'),
     #
     #(r'^view/?', include('view.urls')),
     #(r'^list/slices', 'view.list.slices')
index 1973028..236deaf 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)
 
             var username = this.options.username;
 
-            this.spin();
             console.log("do_update in progress");
 
             manifold.raise_event(this.options.query_uuid, RUN_UPDATE);
 
         },
 
-        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';
 
         on_query_in_progress: function()
         {
-            this.spin();
         },
 
         on_query_done: function()
         {
             this.populate_table();
-            this.unspin();
         },
 
         // D : Data present
 
         on_clear_records: function()
         {
+                $('#applyloading').hide();
             this.clear();
         },
 
         on_query_done: function()
         {
-            this.unspin();
+            $('#applyloading').hide();
         },
 
         // PC : Pending changes
index 6507012..1a9e805 100644 (file)
@@ -1,11 +1,18 @@
 <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">
           <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
-            <h4 class="modal-title" id="{{domid}}__apply__label">Applying pending changes...</h4>
+            <h4 class="modal-title" id="{{domid}}__apply__label">
+               Applying pending changes...
+               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+               <img id="applyloading" src="/static/img/loading.gif" />
+            </h4>
+            <div>
+               Please be patient, this operation can take a minute or two.
+            </div>
         </div>
         <div class="modal-body">
 <div class='resources-selected-spacer'>
@@ -28,7 +35,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 +43,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 0cb9698..fee3a7d 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 fb9f642..bf033e6 100644 (file)
@@ -5,7 +5,7 @@ from sfa.trust.certificate              import Keypair
 #
 from manifold.core.query                import Query
 from manifoldapi.manifoldapi            import execute_query
-from portal.actions                     import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user, sfa_get_user
+from portal.actions                     import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user, sfa_get_user, clear_user_creds
 #
 from unfold.page                        import Page    
 from ui.topmenu                         import topmenu_items_live, the_user
@@ -252,6 +252,7 @@ def account_process(request):
     # getting the user_id from the session
     for user_detail in user_details:
             user_id = user_detail['user_id']
+            user_email = user_detail['email']
 
     for account_detail in account_details:
         for platform_detail in platform_details:
@@ -509,28 +510,16 @@ def account_process(request):
 
     #clear all creds
     elif 'clear_cred' in request.POST:
-        for account_detail in account_details:
-            for platform_detail in platform_details:
-                if platform_detail['platform_id'] == account_detail['platform_id']:
-                    if 'myslice' in platform_detail['platform']:
-                        account_config = json.loads(account_detail['config'])
-                        user_cred = account_config.get('delegated_user_credential','N/A')
-                        if 'N/A' not in user_cred:
-                            user_hrn = account_config.get('user_hrn','N/A')
-                            user_pub_key = json.dumps(account_config.get('user_public_key','N/A'))
-                            user_priv_key = json.dumps(account_config.get('user_private_key','N/A'))
-                            updated_config = '{"user_public_key":'+ user_pub_key + ', "user_private_key":'+ user_priv_key + ', "user_hrn":"'+ user_hrn + '"}'
-                            user_params = { 'config': updated_config}
-                            manifold_update_account(request,user_id, user_params)
-                            messages.success(request, 'All Credentials cleared')
-                            return HttpResponseRedirect("/portal/account/")
-                        else:
-                            messages.error(request, 'Delete error: Credentials are not stored in the server')
-                            return HttpResponseRedirect("/portal/account/")
-        else:
+        try:
+            result = clear_user_creds(request, user_email)
+            if result is not None: 
+                messages.success(request, 'All Credentials cleared')
+            else:
+                messages.error(request, 'Delete error: Credentials are not stored in the server')
+        except Exception,e:
+            print "Exception in accountview.py in clear_user_creds %s" % e
             messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
-            return HttpResponseRedirect("/portal/account/")
-
+        return HttpResponseRedirect("/portal/account/")
 
     # Download delegated_user_cred
     elif 'dl_user_cred' in request.POST:
index b399ca2..5f17385 100644 (file)
@@ -49,6 +49,44 @@ def authority_get_pi_emails(request, authority_hrn):
         results = execute_admin_query(request, query)
         return [result['user_email'] for result in results]
 
+#clear user credentials
+def clear_user_creds(request, user_email):
+    try:
+        user_query  = Query().get('local:user').filter_by('email', '==', user_email).select('user_id','email','password','config')
+        user_details = execute_admin_query(request, user_query)
+    
+        # getting the user_id from the session
+        for user_detail in user_details:
+            user_id = user_detail['user_id']
+            user_email = user_detail['email']
+    
+        account_query  = Query().get('local:account').filter_by('user_id', '==', user_id).select('user_id','platform_id','auth_type','config')
+        account_details = execute_admin_query(request, account_query)
+    
+        platform_query  = Query().get('local:platform').select('platform_id','platform')
+        platform_details = execute_admin_query(request, platform_query)
+    
+        for account_detail in account_details:
+            for platform_detail in platform_details:
+                if platform_detail['platform_id'] == account_detail['platform_id']:
+                    if 'myslice' in platform_detail['platform']:
+                        account_config = json.loads(account_detail['config'])
+                        user_cred = account_config.get('delegated_user_credential','N/A')
+                        if 'N/A' not in user_cred:
+                            user_hrn = account_config.get('user_hrn','N/A')
+                            user_pub_key = json.dumps(account_config.get('user_public_key','N/A'))
+                            user_priv_key = json.dumps(account_config.get('user_private_key','N/A'))
+                            updated_config = '{"user_public_key":'+ user_pub_key + ', "user_private_key":'+ user_priv_key + ', "user_hrn":"'+ user_hrn + '"}'
+                            user_params = { 'config': updated_config}
+                            manifold_update_account(request, user_id,user_params)
+                            return user_email
+                        else:
+                            return None
+
+    except Exception,e:
+        print "Exception in actions.py in clear_user_creds %s" % e
+        return None
+
 def is_pi(wsgi_request, user_hrn, authority_hrn):
     # XXX could be done in a single query !
 
index c4a99ca..ef46644 100644 (file)
@@ -104,6 +104,7 @@ class HomeView (FreeAccessView, ThemeView):
 
     def get (self, request, state=None):
         env = self.default_env()
+        acc_auth_cred={}
         if request.user.is_authenticated():
             ## check user is pi or not
             platform_query  = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
@@ -111,9 +112,9 @@ class HomeView (FreeAccessView, ThemeView):
             # XXX Something like an invalid session seems to make the execute fail sometimes, and thus gives an error on the main page
             platform_details = execute_query(self.request, platform_query)
             account_details = execute_query(self.request, account_query)
-            if platform_details:
-                for platform_detail in platform_details:
-                    for account_detail in account_details:
+            for platform_detail in platform_details:
+                for account_detail in account_details:
+                    if 'platform_id' in platform_detail:
                         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'])
index f9eed28..d28daba 100644 (file)
@@ -93,6 +93,16 @@ class JoinView (FreeAccessView, ThemeView):
                 errors.append('First Name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
             if (re.search(r'^[\w+\s.@+-]+$', reg_lname) == None):
                 errors.append('Last Name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
+            if (re.search(r'^[A-Za-z0-9_ ]*$', reg_site_name) == None):
+                errors.append('Name of organization  may contain only letters, numbers, and underscore.')
+            if (re.search(r'^[A-Za-z ]*$', reg_address_city) == None):
+                errors.append('City may contain only letters.')
+            if (re.search(r'^[A-Za-z ]*$', reg_address_country) == None):
+                errors.append('Country may contain only letters.')
+            if (re.search(r'^[A-Za-z0-9]*$', reg_site_abbreviated_name) == None):
+                errors.append('Shortname  may contain only letters and numbers')
+            if (re.search(r'^[0-9]*$', reg_phone) == None):
+                errors.append('Phone number may contain only numbers.')
             #if (re.search(r'^\w+$', reg_site_authority) == None):
             #    errors.append('Site Authority may contain only letters or numbers.')
             # checking in django_db !!
index 3cbb91d..52a69da 100644 (file)
@@ -399,7 +399,7 @@ def user_process(request, **kwargs):
                             return HttpResponseRedirect(redirect_url)
         else:
             messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
-            return HttpResponseRedirect("/portal/account/")
+            return HttpResponseRedirect(redirect_url)
 
     elif 'dl_pubkey' in request.POST:
         for account_detail in account_details:
@@ -433,7 +433,7 @@ def user_process(request, **kwargs):
 
         else:
             messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
-            return HttpResponseRedirect("/portal/account/")
+            return HttpResponseRedirect(redirect_url)
     
 #    elif 'delete' in request.POST:
 #        for account_detail in account_details:
@@ -476,7 +476,7 @@ def user_process(request, **kwargs):
                             user_params = { 'config': updated_config}
                             manifold_update_account(request, user_id,user_params)
                             messages.success(request, 'All Credentials cleared')
-                            return HttpResponseRedirect("/portal/account/")
+                            return HttpResponseRedirect(redirect_url)
                         else:
                             messages.error(request, 'Delete error: Credentials are not stored in the server')
                             return HttpResponseRedirect(redirect_url)
index a94f650..c4c00db 100644 (file)
@@ -7,7 +7,7 @@ from unfold.page                import Page
 from manifold.core.query        import Query
 from manifoldapi.manifoldapi    import execute_admin_query, execute_query
 
-from portal.actions             import is_pi, create_slice, create_pending_slice
+from portal.actions             import is_pi, create_slice, create_pending_slice, clear_user_creds
 #from portal.forms               import SliceRequestForm
 from unfold.loginrequired       import LoginRequiredAutoLogoutView
 from ui.topmenu                 import topmenu_items_live, the_user
@@ -154,6 +154,7 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
                 if is_pi(wsgi_request, user_hrn, authority_hrn):
                     # PIs can directly create slices in their own authority...
                     create_slice(wsgi_request, slice_request)
+                    clear_user_creds(wsgi_request, user_email)
                     self.template_name = 'slice-request-done-view.html'
                 else:
                     # Otherwise a wsgi_request is sent to the PI
index 750b427..37535b6 100644 (file)
@@ -93,13 +93,9 @@ $(document).ready(function() {
        {% endblock %}
 {% endblock container %}
 <div class="loading">
-       <div class="row">
-               <div class="col-xs-11">Loading...</div>
-               <div class="col-xs-1"><img src="{{ STATIC_URL }}/img/loading.gif" /></div>
-       </div>
-       <div class="row">
-               <div class="col-xs-12 message"></div>
-       </div>
+       <div><img src="{{ STATIC_URL }}/img/loading.gif" /> Loading...</div>
+       <div>&nbsp;</div>
+       <div class="message"></div>
 </div>
 </body>
 </html>
index c73e665..04473d5 100644 (file)
 
                 <!-- XXX TODO: for the moment only PIs have access to Update but users that have slice credentials should also have access to that -->
 
-                               {% if 'is_pi'  in pi %}
                                <button id="addusers" type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> Update users</button>
-                               {%endif%}
                </div>
 
diff --git a/rest/credentials.py b/rest/credentials.py
new file mode 100644 (file)
index 0000000..d63babf
--- /dev/null
@@ -0,0 +1,22 @@
+from django.http                    import HttpResponse
+from portal.actions import clear_user_creds
+import json
+
+def dispatch(request, action):
+    
+    if (action == 'clear') :
+        res=[]
+        emails = request.POST.getlist('emails[]')
+        if emails :
+            for email in emails :
+                try :
+                    res.append(clear_user_creds(request, email))
+                except :
+                    pass
+        
+        if not res :
+            ret = { "ret" : 1, "emails" : res }
+        else :
+            ret = { "ret" : 0 }
+    
+    return HttpResponse(json.dumps(ret), content_type="application/json")