fixes #1512
This commit is contained in:
@@ -74,7 +74,7 @@ private
|
||||
end
|
||||
|
||||
def ban_expired?
|
||||
CurrentUser.user.is_banned? && CurrentUser.user.ban && CurrentUser.user.ban.expired?
|
||||
CurrentUser.user.is_banned? && CurrentUser.user.recent_ban && CurrentUser.user.recent_ban.expired?
|
||||
end
|
||||
|
||||
def cookie_password_hash_valid?
|
||||
|
||||
@@ -97,7 +97,10 @@ class ForumPost < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def update_topic_updated_at_on_destroy
|
||||
topic.update_column(:updated_at, ForumPost.where(:topic_id => topic.id).maximum(:updated_at))
|
||||
max = ForumPost.where(:topic_id => topic.id).maximum(:updated_at)
|
||||
if max
|
||||
topic.update_column(:updated_at, max)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize_creator
|
||||
|
||||
@@ -40,7 +40,8 @@ class User < ActiveRecord::Base
|
||||
before_create :promote_to_admin_if_first_user
|
||||
has_many :feedback, :class_name => "UserFeedback", :dependent => :destroy
|
||||
has_many :posts, :foreign_key => "uploader_id"
|
||||
has_one :ban
|
||||
has_many :bans, :order => "bans.id desc"
|
||||
has_one :recent_ban, :class_name => "Ban", :order => "bans.id desc"
|
||||
has_many :subscriptions, :class_name => "TagSubscription", :foreign_key => "creator_id", :order => "name"
|
||||
has_many :note_versions, :foreign_key => "updater_id"
|
||||
has_many :dmails, :foreign_key => "owner_id", :order => "dmails.id desc"
|
||||
|
||||
@@ -19,7 +19,7 @@ class UserPresenter
|
||||
|
||||
def ban_reason
|
||||
if user.is_banned?
|
||||
"#{user.ban.reason}; expires #{user.ban.expires_at}"
|
||||
"#{user.recent_ban.reason}; expires #{user.recent_ban.expires_at} (#{user.bans.count} bans total)"
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="ui-corner-all ui-state-error" id="ban-notice">
|
||||
<h1>Your account has been temporarily banned</h1>
|
||||
<p>Reason: <%= CurrentUser.user.ban.reason %></p>
|
||||
<p>Your ban will expire in <%= time_ago_in_words(CurrentUser.user.ban.expires_at) %></p>
|
||||
<p>Reason: <%= CurrentUser.user.recent_ban.reason %></p>
|
||||
<p>Your ban will expire in <%= time_ago_in_words(CurrentUser.user.recent_ban.expires_at) %></p>
|
||||
</div>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<% if CurrentUser.is_moderator? %>
|
||||
<li><%= link_to "Promote", edit_admin_user_path(@user) %></li>
|
||||
<% if @user.is_banned? %>
|
||||
<li><%= link_to "Unban", ban_path(@user.ban) %></li>
|
||||
<li><%= link_to "Unban", ban_path(@user.recent_ban) %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "Ban", new_ban_path(:ban => {:user_id => @user.id}) %></li>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user