From: Anton Khorev Date: Thu, 24 Aug 2023 02:35:53 +0000 (+0300) Subject: Change block end column to display strictly ends_at X-Git-Tag: live~4^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/156c526c22fd9f96ffc8667fafaaf10e206a70e4?hp=30da09c5a1d0a788c3becae49cdeee822c23b298 Change block end column to display strictly ends_at Could display when block was viewed before. That's going to be unintuitive if sorting by different times is introduced. --- diff --git a/app/helpers/user_blocks_helper.rb b/app/helpers/user_blocks_helper.rb index a1cd26308..8a3a8a3eb 100644 --- a/app/helpers/user_blocks_helper.rb +++ b/app/helpers/user_blocks_helper.rb @@ -29,16 +29,20 @@ module UserBlocksHelper if block.active? if block.needs_view? if block.ends_at > Time.now.utc - t("user_blocks.helper.short.until_end_and_login") + t("user_blocks.helper.short.active_unread") else - t("user_blocks.helper.short.until_login") + t("user_blocks.helper.short.expired_unread") end else - t("user_blocks.helper.short.until_end") + t("user_blocks.helper.short.active") end else if block.revoker_id.nil? - t("user_blocks.helper.short.ended") + if block.updated_at > block.ends_at + t("user_blocks.helper.short.read_html", :time => block_short_time_in_past(block.updated_at)) + else + t("user_blocks.helper.short.ended") + end else t("user_blocks.helper.short.revoked_html", :name => link_to(block.revoker.display_name, block.revoker, :class => "username d-inline-block text-truncate text-wrap align-bottom", diff --git a/app/views/user_blocks/_block.html.erb b/app/views/user_blocks/_block.html.erb index ef790103e..cbc2ee23c 100644 --- a/app/views/user_blocks/_block.html.erb +++ b/app/views/user_blocks/_block.html.erb @@ -7,10 +7,10 @@ <% end %> <%= h truncate(block.reason) %> <%= block_short_time_in_past(block.created_at) %> - <% if block.active? %> + <% if block.ends_at > Time.now.utc %> <%= block_short_time_in_future(block.ends_at) %> <% else %> - <%= block_short_time_in_past([block.ends_at, block.updated_at].max) %> + <%= block_short_time_in_past(block.ends_at) %> <% end %> <%= h block_short_status(block) %> <%= link_to t(".show"), block %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 6baa96331..4fdc9741c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2898,9 +2898,10 @@ en: short: ended: "ended" revoked_html: "revoked by %{name}" - until_end: "until end" - until_login: "until login" - until_end_and_login: "until end & login" + active: "active" + active_unread: "active unread" + expired_unread: "expired unread" + read_html: "read at %{time}" time_in_future_title: "%{time_absolute}; in %{time_relative}" time_in_past_title: "%{time_absolute}; %{time_relative}" blocks_on: