Show previous usernames to members; link to actual change requests.
This commit is contained in:
@@ -89,6 +89,7 @@ class User < ActiveRecord::Base
|
|||||||
has_many :dmails, lambda {order("dmails.id desc")}, :foreign_key => "owner_id"
|
has_many :dmails, lambda {order("dmails.id desc")}, :foreign_key => "owner_id"
|
||||||
has_many :saved_searches
|
has_many :saved_searches
|
||||||
has_many :forum_posts, lambda {order("forum_posts.created_at")}, :foreign_key => "creator_id"
|
has_many :forum_posts, lambda {order("forum_posts.created_at")}, :foreign_key => "creator_id"
|
||||||
|
has_many :user_name_change_requests, lambda {visible.order("user_name_change_requests.created_at desc")}
|
||||||
belongs_to :inviter, :class_name => "User"
|
belongs_to :inviter, :class_name => "User"
|
||||||
after_update :create_mod_action
|
after_update :create_mod_action
|
||||||
accepts_nested_attributes_for :dmail_filter
|
accepts_nested_attributes_for :dmail_filter
|
||||||
|
|||||||
@@ -19,6 +19,16 @@ class UserNameChangeRequest < ActiveRecord::Base
|
|||||||
where(:status => "approved")
|
where(:status => "approved")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.visible
|
||||||
|
if CurrentUser.is_admin?
|
||||||
|
all
|
||||||
|
elsif CurrentUser.is_member?
|
||||||
|
where("user_name_change_requests.status = 'approved' OR user_name_change_requests.user_id = ?", CurrentUser.id)
|
||||||
|
else
|
||||||
|
none
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def rejected?
|
def rejected?
|
||||||
status == "rejected"
|
status == "rejected"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ class UserPresenter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def previous_names
|
def previous_names(template)
|
||||||
UserNameChangeRequest.approved.where("user_id = ?", user.id).map(&:original_name).join(", ")
|
user.user_name_change_requests.map { |req| template.link_to req.original_name, req }.join(", ").html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -138,10 +138,10 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% if CurrentUser.is_moderator? && presenter.previous_names.present? %>
|
<% if presenter.previous_names(self).present? %>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Previous Names</th>
|
<th>Previous Names</th>
|
||||||
<td><%= presenter.previous_names %></td>
|
<td><%= presenter.previous_names(self) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user