users: reword ban notice messages.
* Show the ban length instead of the ban expiration date in ban notices. * Fix the ban notice to not say "Your account has been temporarily banned" when it's a permanent ban.
This commit is contained in:
@@ -98,17 +98,12 @@ module ApplicationHelper
|
|||||||
tag.time content || datetime, datetime: datetime, title: time.to_formatted_s, **options
|
tag.time content || datetime, datetime: datetime, title: time.to_formatted_s, **options
|
||||||
end
|
end
|
||||||
|
|
||||||
def humanized_duration(from, to)
|
def humanized_duration(duration)
|
||||||
if to - from > 10.years
|
if duration >= 100.years
|
||||||
duration = "forever"
|
"forever"
|
||||||
else
|
else
|
||||||
duration = distance_of_time_in_words(from, to)
|
duration.inspect
|
||||||
end
|
end
|
||||||
|
|
||||||
datetime = from.iso8601 + "/" + to.iso8601
|
|
||||||
title = "#{from.strftime("%Y-%m-%d %H:%M")} to #{to.strftime("%Y-%m-%d %H:%M")}"
|
|
||||||
|
|
||||||
raw content_tag(:time, duration, datetime: datetime, title: title)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def humanized_number(number)
|
def humanized_number(number)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class Ban < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def humanized_duration
|
def humanized_duration
|
||||||
ApplicationController.helpers.distance_of_time_in_words(created_at, expires_at)
|
ApplicationController.helpers.humanized_duration(duration)
|
||||||
end
|
end
|
||||||
|
|
||||||
def expired?
|
def expired?
|
||||||
@@ -72,11 +72,11 @@ class Ban < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_feedback
|
def create_feedback
|
||||||
user.feedback.create!(creator: banner, category: "negative", body: "Banned for #{humanized_duration}: #{reason}")
|
user.feedback.create!(creator: banner, category: "negative", body: "Banned #{humanized_duration}: #{reason}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_ban_mod_action
|
def create_ban_mod_action
|
||||||
ModAction.log(%{Banned <@#{user_name}> for #{humanized_duration}: #{reason}}, :user_ban)
|
ModAction.log(%{Banned <@#{user_name}> #{humanized_duration}: #{reason}}, :user_ban)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_unban_mod_action
|
def create_unban_mod_action
|
||||||
|
|||||||
@@ -13,14 +13,6 @@ class UserPresenter
|
|||||||
user.created_at.strftime("%Y-%m-%d")
|
user.created_at.strftime("%Y-%m-%d")
|
||||||
end
|
end
|
||||||
|
|
||||||
def ban_reason
|
|
||||||
if user.is_banned?
|
|
||||||
"#{user.active_ban.reason}; expires #{user.active_ban.expires_at} (#{user.bans.count} bans total)"
|
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def permissions
|
def permissions
|
||||||
permissions = []
|
permissions = []
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% t.column "Duration" do |ban| %>
|
<% t.column "Duration" do |ban| %>
|
||||||
<%= humanized_duration(ban.created_at, ban.expires_at) %>
|
<%= humanized_duration(ban.duration) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% t.column "Banner" do |ban| %>
|
<% t.column "Banner" do |ban| %>
|
||||||
<%= link_to_user ban.banner %>
|
<%= link_to_user ban.banner %>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<h1>Show Ban</h1>
|
<h1>Show Ban</h1>
|
||||||
<ul style="margin-bottom: 1em;">
|
<ul style="margin-bottom: 1em;">
|
||||||
<li><strong>User</strong> <%= link_to_user(@ban.user) %></li>
|
<li><strong>User</strong> <%= link_to_user(@ban.user) %></li>
|
||||||
<li><strong>Duration</strong> <%= humanized_duration(@ban.created_at, @ban.expires_at) %></li>
|
<li><strong>Duration</strong> <%= humanized_duration(@ban.duration) %></li>
|
||||||
<li>
|
<li>
|
||||||
<strong>Reason</strong>
|
<strong>Reason</strong>
|
||||||
<div class="prose">
|
<div class="prose">
|
||||||
|
|||||||
@@ -81,9 +81,7 @@
|
|||||||
<%= render "users/upgrade_notice" %>
|
<%= render "users/upgrade_notice" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if CurrentUser.user.is_banned? %>
|
<%= render "users/ban_notice" %>
|
||||||
<%= render "users/ban_notice" %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if params[:controller] != "dmails" && has_unread_dmails?(CurrentUser.user) %>
|
<% if params[:controller] != "dmails" && has_unread_dmails?(CurrentUser.user) %>
|
||||||
<%= render "users/dmail_notice" %>
|
<%= render "users/dmail_notice" %>
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<div class="notice notice-error notice-large" id="ban-notice">
|
<% if CurrentUser.user.is_banned? %>
|
||||||
<h2>Your account has been temporarily banned</h2>
|
<% @active_ban = CurrentUser.user.active_ban %>
|
||||||
<div>Reason: <span class="prose"><%= format_text CurrentUser.user.active_ban.reason, inline: true %></span></div>
|
|
||||||
<div>Your ban will expire in <%= time_ago_in_words(CurrentUser.user.active_ban.expires_at) %></div>
|
<div class="notice notice-error notice-large" id="ban-notice">
|
||||||
</div>
|
<h2>You have been banned <%= humanized_duration @active_ban.duration %></h2>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
Reason: <span class="prose"><%= format_text @active_ban.reason, inline: true %></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -89,12 +89,13 @@
|
|||||||
<td><%= presenter.permissions %></td>
|
<td><%= presenter.permissions %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% if user.is_banned? %>
|
<% if user.is_banned? && user.active_ban.present? %>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Ban reason</th>
|
<th>Ban reason</th>
|
||||||
<td>
|
<td>
|
||||||
<span class="prose">
|
<span class="prose">
|
||||||
<%= format_text presenter.ban_reason, inline: true %>
|
<%= format_text user.active_ban.reason, inline: true %>
|
||||||
|
(banned <%= humanized_duration(user.active_ban.duration) %>)
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user