post/comment/forum votes: add vote counts to profile pages.
* Add post/comment/forum vote counts to user profiles. * Show uploaders on post votes index and allow searching by uploader. * Show forum posters on forum votes index and allow searching by poster. * Add unvote link to forum votes index. * Only show unvote links to current user.
This commit is contained in:
@@ -8,9 +8,15 @@ class ForumPostVote < ApplicationRecord
|
||||
scope :by, ->(user_id) {where(creator_id: user_id)}
|
||||
scope :excluding_user, ->(user_id) {where("creator_id <> ?", user_id)}
|
||||
|
||||
def self.forum_post_matches(params)
|
||||
return all if params.blank?
|
||||
where(forum_post_id: ForumPost.search(params).reorder(nil).select(:id))
|
||||
end
|
||||
|
||||
def self.search(params)
|
||||
q = super
|
||||
q = q.search_attributes(params, :creator, :forum_post_id, :score)
|
||||
q = q.forum_post_matches(params[:forum_post])
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ class User < ApplicationRecord
|
||||
has_many :artist_versions, foreign_key: :updater_id
|
||||
has_many :artist_commentary_versions, foreign_key: :updater_id
|
||||
has_many :comments, foreign_key: :creator_id
|
||||
has_many :comment_votes, dependent: :destroy
|
||||
has_many :wiki_page_versions, foreign_key: :updater_id
|
||||
has_many :feedback, :class_name => "UserFeedback", :dependent => :destroy
|
||||
has_many :forum_post_votes, dependent: :destroy, foreign_key: :creator_id
|
||||
|
||||
Reference in New Issue
Block a user