fixes #1930
This commit is contained in:
@@ -26,6 +26,10 @@ class PostAppeal < ActiveRecord::Base
|
||||
where("created_at >= ?", 1.day.ago)
|
||||
end
|
||||
|
||||
def for_creator(user_id)
|
||||
where("creator_id = ?", user_id)
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
return q if params.blank?
|
||||
|
||||
@@ -27,6 +27,10 @@ class PostFlag < ActiveRecord::Base
|
||||
where("created_at <= ?", 3.days.ago)
|
||||
end
|
||||
|
||||
def for_creator(user_id)
|
||||
where("creator_id = ?", user_id)
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
return q if params.blank?
|
||||
|
||||
@@ -524,7 +524,7 @@ class User < ActiveRecord::Base
|
||||
options[:except] ||= []
|
||||
options[:except] += hidden_attributes
|
||||
options[:methods] ||= []
|
||||
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count, :positive_feedback_count, :neutral_feedback_count, :negative_feedback_count]
|
||||
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count, :appeal_count, :flag_count, :positive_feedback_count, :neutral_feedback_count, :negative_feedback_count]
|
||||
super(options)
|
||||
end
|
||||
|
||||
@@ -534,7 +534,7 @@ class User < ActiveRecord::Base
|
||||
options[:except] ||= []
|
||||
options[:except] += hidden_attributes
|
||||
options[:methods] ||= []
|
||||
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count, :positive_feedback_count, :neutral_feedback_count, :negative_feedback_count]
|
||||
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count, :appeal_count, :flag_count, :positive_feedback_count, :neutral_feedback_count, :negative_feedback_count]
|
||||
super(options, &block)
|
||||
end
|
||||
|
||||
@@ -569,6 +569,14 @@ class User < ActiveRecord::Base
|
||||
Comment.for_creator(id).count
|
||||
end
|
||||
|
||||
def appeal_count
|
||||
PostAppeal.for_creator(id).count
|
||||
end
|
||||
|
||||
def flag_count
|
||||
PostFlag.for_creator(id).count
|
||||
end
|
||||
|
||||
def positive_feedback_count
|
||||
feedback.positive.count
|
||||
end
|
||||
|
||||
@@ -137,6 +137,14 @@ class UserPresenter
|
||||
end
|
||||
end
|
||||
|
||||
def appeal_count(template)
|
||||
template.link_to(user.appeal_count, template.post_appeals_path(:search => {:creator_id => user.id}))
|
||||
end
|
||||
|
||||
def flag_count(template)
|
||||
template.link_to(user.flag_count, template.post_flags_path(:search => {:creator_id => user.id}))
|
||||
end
|
||||
|
||||
def approval_count(template)
|
||||
template.link_to(Post.where("approver_id = ?", user.id).count, template.posts_path(:tags => "approver:#{user.name}"))
|
||||
end
|
||||
|
||||
@@ -92,6 +92,20 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Appeals</th>
|
||||
<td><%= presenter.appeal_count(self) %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% if CurrentUser.user.id == user.id || CurrentUser.user.is_janitor? %>
|
||||
<tr>
|
||||
<th>Flags</th>
|
||||
<td><%= presenter.flag_count(self) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<tr>
|
||||
<th>Feedback</th>
|
||||
<td><%= presenter.feedbacks(self) %></td> </tbody>
|
||||
|
||||
Reference in New Issue
Block a user