]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/user_blocks_controller.rb
Add revoke all blocks action
[rails.git] / app / controllers / user_blocks_controller.rb
index a671f0d16f67112eb3dcf508a3fc585f16b2493e..07d0bc43c0bf2e64138a24ad2b0af41cbcf9bb2b 100644 (file)
@@ -12,7 +12,7 @@ class UserBlocksController < ApplicationController
   before_action :lookup_user_block, :only => [:show, :edit, :update, :revoke]
   before_action :require_valid_params, :only => [:create, :update]
   before_action :check_database_readable
-  before_action :check_database_writable, :only => [:create, :update, :revoke]
+  before_action :check_database_writable, :only => [:create, :update, :revoke, :revoke_all]
 
   def index
     @params = params.permit
@@ -92,7 +92,11 @@ class UserBlocksController < ApplicationController
   ##
   # revokes all active blocks
   def revoke_all
-    # TODO revoke
+    if request.post? && params[:confirm]
+      @user.blocks.active.each { |block| block.revoke!(current_user) }
+      flash[:notice] = t ".flash"
+      redirect_to user_blocks_on_path(@user)
+    end
   end
 
   ##