X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/c49e400aa36d116ded8188240961d1e88b172ccd..ba53dc7b04b4f081f748f2c506b25a3a6563f63d:/app/controllers/user_blocks_controller.rb?ds=sidebyside diff --git a/app/controllers/user_blocks_controller.rb b/app/controllers/user_blocks_controller.rb index 63fca6557..bf61f906b 100644 --- a/app/controllers/user_blocks_controller.rb +++ b/app/controllers/user_blocks_controller.rb @@ -1,4 +1,6 @@ class UserBlocksController < ApplicationController + include UserMethods + layout "site" before_action :authorize_web @@ -32,16 +34,18 @@ class UserBlocksController < ApplicationController end def edit - params[:user_block_period] = ((@user_block.ends_at - Time.now.getutc) / 1.hour).ceil.to_s + params[:user_block_period] = ((@user_block.ends_at - Time.now.utc) / 1.hour).ceil.to_s end def create if @valid_params + now = Time.now.utc @user_block = UserBlock.new( :user => @user, :creator => current_user, :reason => params[:user_block][:reason], - :ends_at => Time.now.getutc + @block_period.hours, + :created_at => now, + :ends_at => now + @block_period.hours, :needs_view => params[:user_block][:needs_view] ) @@ -62,7 +66,7 @@ class UserBlocksController < ApplicationController flash[:error] = t(".only_creator_can_edit") redirect_to :action => "edit" elsif @user_block.update( - :ends_at => Time.now.getutc + @block_period.hours, + :ends_at => Time.now.utc + @block_period.hours, :reason => params[:user_block][:reason], :needs_view => params[:user_block][:needs_view] ) @@ -85,6 +89,12 @@ class UserBlocksController < ApplicationController end end + ## + # revokes all active blocks + def revoke_all + # TODO revoke + end + ## # shows a list of all the blocks on the given user def blocks_on