]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/user_blocks_controller.rb
Merge remote-tracking branch 'upstream/pull/5090'
[rails.git] / app / controllers / user_blocks_controller.rb
index 3b7ef30f9c96256962187173e5ee317408e05d58..ae6e3c1cd5f4f3b7fc26646cd8ae346ebdb75cb1 100644 (file)
@@ -72,14 +72,18 @@ class UserBlocksController < ApplicationController
         @user_block.reason = params[:user_block][:reason]
         @user_block.needs_view = params[:user_block][:needs_view]
         @user_block.ends_at = Time.now.utc + @block_period.hours
+        @user_block.revoker = current_user if user_block_was_active && !@user_block.active?
         if !user_block_was_active && @user_block.active?
           flash.now[:error] = t(".inactive_block_cannot_be_reactivated")
           render :action => "edit"
-        elsif @user_block.save
-          flash[:notice] = t(".success")
-          redirect_to @user_block
         else
-          render :action => "edit"
+          @user_block.ends_at = @user_block.ends_at_was unless user_block_was_active
+          if @user_block.save
+            flash[:notice] = t(".success")
+            redirect_to @user_block
+          else
+            render :action => "edit"
+          end
         end
       end
     else