]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/user_blocks_controller.rb
Merge remote-tracking branch 'upstream/pull/5091'
[rails.git] / app / controllers / user_blocks_controller.rb
index 3b7ef30f9c96256962187173e5ee317408e05d58..962eff04ce06306cb97906d9d4a0edf2c126e4bc 100644 (file)
@@ -75,11 +75,14 @@ class UserBlocksController < ApplicationController
         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