post votes: let gold users use upvote:self, downvote:self metatags.
* Let gold users use upvote:self, downvote:self metatags to search for their own votes. * Don't let mods use upvote:<user>, downvote:<user> metatags to see votes by other users. Only let admins see other users' votes. * Add vote count to profile page.
This commit is contained in:
@@ -473,14 +473,12 @@ class PostQueryBuilder
|
|||||||
end
|
end
|
||||||
|
|
||||||
if q[:upvote].present?
|
if q[:upvote].present?
|
||||||
user_id = q[:upvote]
|
post_ids = PostVote.where(user: q[:upvote]).where("score > 0").select(:post_id)
|
||||||
post_ids = PostVote.where(:user_id => user_id).where("score > 0").limit(400).pluck(:post_id)
|
|
||||||
relation = relation.where("posts.id": post_ids)
|
relation = relation.where("posts.id": post_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
if q[:downvote].present?
|
if q[:downvote].present?
|
||||||
user_id = q[:downvote]
|
post_ids = PostVote.where(user: q[:downvote]).where("score < 0").select(:post_id)
|
||||||
post_ids = PostVote.where(:user_id => user_id).where("score < 0").limit(400).pluck(:post_id)
|
|
||||||
relation = relation.where("posts.id": post_ids)
|
relation = relation.where("posts.id": post_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -774,13 +774,17 @@ class Tag < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
when "upvote"
|
when "upvote"
|
||||||
if CurrentUser.user.is_moderator?
|
if CurrentUser.user.is_admin?
|
||||||
q[:upvote] = User.name_to_id(g2)
|
q[:upvote] = User.find_by_name(g2)
|
||||||
|
elsif CurrentUser.user.is_voter?
|
||||||
|
q[:upvote] = CurrentUser.user
|
||||||
end
|
end
|
||||||
|
|
||||||
when "downvote"
|
when "downvote"
|
||||||
if CurrentUser.user.is_moderator?
|
if CurrentUser.user.is_admin?
|
||||||
q[:downvote] = User.name_to_id(g2)
|
q[:downvote] = User.find_by_name(g2)
|
||||||
|
elsif CurrentUser.user.is_voter?
|
||||||
|
q[:downvote] = CurrentUser.user
|
||||||
end
|
end
|
||||||
|
|
||||||
when *COUNT_METATAGS
|
when *COUNT_METATAGS
|
||||||
|
|||||||
@@ -85,6 +85,15 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<% if CurrentUser.user == user || CurrentUser.user.is_admin? %>
|
||||||
|
<tr>
|
||||||
|
<th>Post Votes</th>
|
||||||
|
<td>
|
||||||
|
<%= link_to user.post_votes.count, post_votes_path(search: { user_name: user.name }) %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Favorite Groups</th>
|
<th>Favorite Groups</th>
|
||||||
<td><%= presenter.favorite_group_count(self) %></td>
|
<td><%= presenter.favorite_group_count(self) %></td>
|
||||||
|
|||||||
Reference in New Issue
Block a user