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