incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [29/33] git commit: [#6392] ticket:444 added ajax for block form
Date Tue, 24 Sep 2013 19:38:05 GMT
[#6392] ticket:444 added ajax for block form


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/83903bb0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/83903bb0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/83903bb0

Branch: refs/heads/cj/6695
Commit: 83903bb0e62c9488209438a01b79d3dac719453b
Parents: 323d01c
Author: coldmind <sokandpal@yandex.ru>
Authored: Thu Sep 19 14:07:31 2013 +0300
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Sep 24 17:36:25 2013 +0000

----------------------------------------------------------------------
 Allura/allura/app.py                            |  6 +++---
 .../allura/templates/app_admin_permissions.html | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/83903bb0/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 74d9c4d..b88f23a 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -585,14 +585,14 @@ class DefaultAdminController(BaseController):
         """
         permanent_redirect('permissions')
 
-    @expose()
+    @expose('json:')
+    @require_post()
     def block_user(self, username, perm, reason=None):
         if not username or not perm:
             redirect(request.referer)
         user = model.User.by_username(username)
         if not user:
-            flash('User "%s" not found' % username, 'error')
-            redirect(request.referer)
+            return dict(error='User "%s" not found' % username)
         ace = model.ACE.deny(user.project_role()._id, perm, reason)
         if not model.ACL.contains(ace, self.app.acl):
             self.app.acl.append(ace)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/83903bb0/Allura/allura/templates/app_admin_permissions.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/app_admin_permissions.html b/Allura/allura/templates/app_admin_permissions.html
index 7de150e..96471d4 100644
--- a/Allura/allura/templates/app_admin_permissions.html
+++ b/Allura/allura/templates/app_admin_permissions.html
@@ -78,5 +78,25 @@
       $('input.block_user_role').val(role);
       $('div.model-block-list').html(userlist.html());
   });
+  $('form[action="block_user"]').submit(function() {
+    var form = $(this);
+    if($(this).is(':visible')) {
+        $.ajax({
+            data: $(this).serialize(),
+            type: $(this).attr('method'),
+            url: $(this).attr('action'),
+            success: function(data) {
+                if(data.error){
+                  flash(data.error, 'error');
+                }
+                else {
+                  form.parent().slideUp('fast');
+                  $('.lb_overlay').hide();
+                }
+              }
+            });
+        return false;
+    }
+  });
 </script>
 {% endblock %}


Mime
View raw message