allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [46/50] git commit: [#6392] ticket:444 dynamic add/remove blocked user in list
Date Thu, 26 Sep 2013 18:30:04 GMT
[#6392] ticket:444 dynamic add/remove blocked user in list


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

Branch: refs/heads/tv/6612
Commit: 170205b54fae9a278f73b6ef8aa2cad7b2e38b03
Parents: 2a57013
Author: coldmind <sokandpal@yandex.ru>
Authored: Thu Sep 19 16:45:36 2013 +0300
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Sep 24 17:36:25 2013 +0000

----------------------------------------------------------------------
 Allura/allura/app.py                            |  2 +-
 .../allura/templates/app_admin_permissions.html | 44 ++++++++++++++++----
 2 files changed, 37 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/170205b5/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index d172a65..e51b70a 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -596,7 +596,7 @@ class DefaultAdminController(BaseController):
         ace = model.ACE.deny(user.project_role()._id, perm, reason)
         if not model.ACL.contains(ace, self.app.acl):
             self.app.acl.append(ace)
-        redirect(request.referer)
+        return dict(user_id=str(user._id))
 
     @validate(dict(user_id=V.Set(),
                    perm=V.UnicodeString()))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/170205b5/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 fb5aa61..f14860a 100644
--- a/Allura/allura/templates/app_admin_permissions.html
+++ b/Allura/allura/templates/app_admin_permissions.html
@@ -66,12 +66,15 @@
 {% endblock %}
 {% block extra_js %}
 <script type="text/javascript">
+  var current_block_list;
   $('a.block-user').click(function(){
+      current_block_list = $(this).parent().parent().find('div.block-list')     
       var deck =  $(this).closest('ul.deck');
       var role = deck.find('li.tcenter h3').text();
       $('input.block_user_role').val(role);
   });
   $('a.block-list').click(function(){
+      current_block_list = $(this).siblings('div.block-list')
       var userlist = $(this).siblings('div.block-list').clone();
       var deck =  $(this).closest('ul.deck');
       var role = deck.find('li.tcenter h3').text();
@@ -79,19 +82,44 @@
       $('div.model-block-list').html(userlist.html());
   });
   $('form[action="block_user"], form[action="unblock_user"]').submit(function() {
-    var form = $(this);
-    if($(this).is(':visible')) {
+    var form = $(this),
+        username = form.find('#block_user'),
+        reason = form.find("textarea[name='reason']")
+
+    if(form.is(':visible')) {
         $.ajax({
-            data: $(this).serialize(),
-            type: $(this).attr('method'),
-            url: $(this).attr('action'),
+            data: form.serialize(),
+            type: form.attr('method'),
+            url:  form.attr('action'),
             success: function(data) {
                 if(data.error){
-                  flash(data.error, 'error');
+                    flash(data.error, 'error');
                 }
                 else {
-                  form.parent().slideUp('fast');
-                  $('.lb_overlay').hide();
+                    form.parent().slideUp('fast');
+                    $('.lb_overlay').hide();
+
+                    if(form.attr('action') == 'block_user') {
+                        if(username.val().length != 0) {
+                            current_block_list
+                              .find('ul')
+                              .append('<li><label>' + 
+                                      '<input type="checkbox" value="' + data.user_id
+ '"name="user_id">' +
+                                      username.val() + ' (' +
+                                      reason.val() + ')' +
+                                      '</label></li>');
+                        }
+                    }
+                    else {
+                        var checked = form.find('input:checked');
+                        checked.each(function(i, e) {
+                            current_block_list
+                              .find('label:contains("'+$(e).parent().text()+'")')
+                              .parent()
+                              .remove()
+                        });
+                    }
+                    form.find("input[type=text], textarea").val("");
                 }
               }
             });


Mime
View raw message