[openstreetmap/openstreetmap-website] CRUD interface for moderation zones (PR #7148)

Pablo Brasero notifications at github.com
Tue Jul 28 23:13:38 UTC 2026


@pablobm commented on this pull request.



> +
+module ModerationZonesHelper
+  def options_for_moderation_zone_period
+    ModerationZone::PERIODS.collect do |h|
+      [block_duration_in_words(h.hours), h.to_s]
+    end
+  end
+
+  def selected_option_for_moderation_zone_period(moderation_zone)
+    param_value = params.dig(:moderation_zone, :period)
+    if param_value
+      ModerationZone::PERIODS.min_by do |h|
+        (param_value.to_i - h).abs
+      end
+    elsif moderation_zone.ends_at
+      value_to_compare = ((moderation_zone.ends_at - Time.now.utc) / 1.hour).ceil.to_s

That was the product of porting the code used for user blocks, which is spread over `user_blocks/_new`, `user_blocks/_edit`, and `user_blocks_controller`. Initially I didn't want to innovate too much, in case I broke something unexpectedly. Having said that, once in place it does look odd. I have addressed the points you raised 👍 

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

Message ID: <openstreetmap/openstreetmap-website/pull/7148/review/4802604082 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260728/9468271e/attachment-0001.htm>


More information about the rails-dev mailing list