expose voting to non-gold supervoters
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
class PostVotesController < ApplicationController
|
class PostVotesController < ApplicationController
|
||||||
before_filter :gold_only
|
before_filter :voter_only
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@post = Post.find(params[:post_id])
|
@post = Post.find(params[:post_id])
|
||||||
@@ -7,4 +7,10 @@ class PostVotesController < ApplicationController
|
|||||||
rescue PostVote::Error => x
|
rescue PostVote::Error => x
|
||||||
@error = x
|
@error = x
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def voter_only
|
||||||
|
CurrentUser.is_voter?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -241,6 +241,14 @@ class AnonymousUser
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_voter?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_super_voter?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
%w(member banned gold builder platinum janitor moderator admin).each do |name|
|
%w(member banned gold builder platinum janitor moderator admin).each do |name|
|
||||||
define_method("is_#{name}?") do
|
define_method("is_#{name}?") do
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -401,6 +401,10 @@ class User < ActiveRecord::Base
|
|||||||
level >= Levels::ADMIN
|
level >= Levels::ADMIN
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_voter?
|
||||||
|
is_gold? || is_super_voter?
|
||||||
|
end
|
||||||
|
|
||||||
def create_mod_action
|
def create_mod_action
|
||||||
if level_changed?
|
if level_changed?
|
||||||
ModAction.create(:description => %{"#{name}":/users/#{id} level changed #{level_string_was} -> #{level_string}})
|
ModAction.create(:description => %{"#{name}":/users/#{id} level changed #{level_string_was} -> #{level_string}})
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<strong>Score</strong>
|
<strong>Score</strong>
|
||||||
<span>
|
<span>
|
||||||
<span id="score-for-post-<%= post.id %>"><%= post.score %></span>
|
<span id="score-for-post-<%= post.id %>"><%= post.score %></span>
|
||||||
<% if CurrentUser.is_gold? %>
|
<% if CurrentUser.is_voter? %>
|
||||||
(vote <%= link_to("up", post_votes_path(:score => "up", :post_id => post.id), :remote => true, :method => :post) %>/<%= link_to("down", post_votes_path(:score => "down", :post_id => post.id), :remote => true, :method => :post) %>)
|
(vote <%= link_to("up", post_votes_path(:score => "up", :post_id => post.id), :remote => true, :method => :post) %>/<%= link_to("down", post_votes_path(:score => "down", :post_id => post.id), :remote => true, :method => :post) %>)
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>Source: <%= post_source_tag(post) %></li>
|
<li>Source: <%= post_source_tag(post) %></li>
|
||||||
<li>Rating: <%= post.pretty_rating %></li>
|
<li>Rating: <%= post.pretty_rating %></li>
|
||||||
<li>Score: <span id="score-for-post-<%= post.id %>"><%= post.score %></span> <% if CurrentUser.is_gold? %>(<span id="vote-links-for-post-<%= post.id %>">vote <%= link_to "up", post_votes_path(:post_id => post.id, :score => "up"), :remote => true, :method => :post %>/<%= link_to "down", post_votes_path(:post_id => post.id, :score => "down"), :remote => true, :method => :post %></span><%= link_to "undo vote", unvote_post_path(post), :remote => true, :method => :put, :id => "unvote-link-for-post-#{post.id}", :class => "unvote-post-link" %>)<% end %></li>
|
<li>Score: <span id="score-for-post-<%= post.id %>"><%= post.score %></span> <% if CurrentUser.is_voter? %>(<span id="vote-links-for-post-<%= post.id %>">vote <%= link_to "up", post_votes_path(:post_id => post.id, :score => "up"), :remote => true, :method => :post %>/<%= link_to "down", post_votes_path(:post_id => post.id, :score => "down"), :remote => true, :method => :post %></span><%= link_to "undo vote", unvote_post_path(post), :remote => true, :method => :put, :id => "unvote-link-for-post-#{post.id}", :class => "unvote-post-link" %>)<% end %></li>
|
||||||
<li>Favorites: <span id="favcount-for-post-<%= post.id %>"><%= post.fav_count %></span>
|
<li>Favorites: <span id="favcount-for-post-<%= post.id %>"><%= post.fav_count %></span>
|
||||||
<% if CurrentUser.is_gold? %>
|
<% if CurrentUser.is_gold? %>
|
||||||
<%= link_to "Show »".html_safe, "#", :id => "show-favlist-link" %>
|
<%= link_to "Show »".html_safe, "#", :id => "show-favlist-link" %>
|
||||||
|
|||||||
12
script/fixes/040_fix_post_scores.rb
Normal file
12
script/fixes/040_fix_post_scores.rb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
|
||||||
|
|
||||||
|
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
|
||||||
|
|
||||||
|
CurrentUser.user = User.admins.first
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
|
||||||
|
PostVote.find_each do |vote|
|
||||||
|
vote.destroy unless User.find(vote.user_id).is_gold?
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user