[openstreetmap/openstreetmap-website] Add deactivates_at date to user blocks (PR #5069)

Anton Khorev notifications at github.com
Wed Aug 14 01:12:42 UTC 2024


@AntonKhorev commented on this pull request.



>        else
-        render :action => "edit"
+        user_block_was_active = @user_block.active?
+        @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.deactivates_at = (@user_block.ends_at unless @user_block.needs_view)
+        if !user_block_was_active && !@user_block.active?
+          @user_block.ends_at = @user_block.ends_at_was
+          @user_block.deactivates_at = @user_block.deactivates_at_was
+        end
+        @user_block.deactivates_at = [@user_block.ends_at, @user_block.updated_at].max if !@user_block.deactivates_at && !@user_block.needs_view

This line is needed until backfilling is done, otherwise you can't edit inactive blocks:

        @user_block.deactivates_at = [@user_block.ends_at, @user_block.updated_at].max if !@user_block.deactivates_at && !@user_block.needs_view

I need to capture the updated_at value that may contain the deactivation time before it's ruined by the update.

> should we be allowed an expired block to be reactivated

We decided that we shouldn't and I was going to disable it but I bumped into this deactivation time problem.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5069#discussion_r1716173050
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5069/review/2236943556 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240813/b908560f/attachment.htm>


More information about the rails-dev mailing list