partial fix for #1323
This commit is contained in:
@@ -517,6 +517,8 @@ class User < ActiveRecord::Base
|
|||||||
options ||= {}
|
options ||= {}
|
||||||
options[:except] ||= []
|
options[:except] ||= []
|
||||||
options[:except] += hidden_attributes
|
options[:except] += hidden_attributes
|
||||||
|
options[:methods] ||= []
|
||||||
|
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count]
|
||||||
super(options)
|
super(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -538,6 +540,28 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module CountMethods
|
||||||
|
def wiki_page_version_count
|
||||||
|
WikiPageVersion.for_user(id).count
|
||||||
|
end
|
||||||
|
|
||||||
|
def artist_version_count
|
||||||
|
ArtistVersion.for_user(id).count
|
||||||
|
end
|
||||||
|
|
||||||
|
def pool_version_count
|
||||||
|
PoolVersion.for_user(id).count
|
||||||
|
end
|
||||||
|
|
||||||
|
def forum_post_count
|
||||||
|
ForumPost.for_user(id).count
|
||||||
|
end
|
||||||
|
|
||||||
|
def comment_count
|
||||||
|
Comment.for_creator(id).count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
def named(name)
|
def named(name)
|
||||||
where("lower(name) = ?", name)
|
where("lower(name) = ?", name)
|
||||||
@@ -628,6 +652,7 @@ class User < ActiveRecord::Base
|
|||||||
include LimitMethods
|
include LimitMethods
|
||||||
include InvitationMethods
|
include InvitationMethods
|
||||||
include ApiMethods
|
include ApiMethods
|
||||||
|
include CountMethods
|
||||||
extend SearchMethods
|
extend SearchMethods
|
||||||
|
|
||||||
def initialize_default_image_size
|
def initialize_default_image_size
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class UserPresenter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def comment_count(template)
|
def comment_count(template)
|
||||||
template.link_to(Comment.for_creator(user.id).count, template.comments_path(:search => {:creator_id => user.id}, :group_by => "comment"))
|
template.link_to(user.comment_count, template.comments_path(:search => {:creator_id => user.id}, :group_by => "comment"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def commented_posts_count(template)
|
def commented_posts_count(template)
|
||||||
@@ -100,19 +100,19 @@ class UserPresenter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def wiki_page_version_count(template)
|
def wiki_page_version_count(template)
|
||||||
template.link_to(WikiPageVersion.for_user(user.id).count, template.wiki_page_versions_path(:search => {:updater_id => user.id}))
|
template.link_to(user.wiki_page_version_count, template.wiki_page_versions_path(:search => {:updater_id => user.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def artist_version_count(template)
|
def artist_version_count(template)
|
||||||
template.link_to(ArtistVersion.for_user(user.id).count, template.artist_versions_path(:search => {:updater_id => user.id}))
|
template.link_to(user.artist_version_count, template.artist_versions_path(:search => {:updater_id => user.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def forum_post_count(template)
|
def forum_post_count(template)
|
||||||
template.link_to(ForumPost.for_user(user.id).count, template.forum_posts_path(:search => {:creator_id => user.id}))
|
template.link_to(user.forum_post_count, template.forum_posts_path(:search => {:creator_id => user.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def pool_version_count(template)
|
def pool_version_count(template)
|
||||||
template.link_to(PoolVersion.for_user(user.id).count, template.pool_versions_path(:search => {:updater_id => user.id}))
|
template.link_to(user.pool_version_count, template.pool_versions_path(:search => {:updater_id => user.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def inviter(template)
|
def inviter(template)
|
||||||
|
|||||||
Reference in New Issue
Block a user