forked from e621ng/e621ng
add antivoters (no behavior yet)
This commit is contained in:
parent
bf2246f895
commit
b2e6a8f031
8
app/controllers/anti_voters_controller.rb
Normal file
8
app/controllers/anti_voters_controller.rb
Normal file
@ -0,0 +1,8 @@
|
||||
class AntiVotersController < ApplicationController
|
||||
before_filter :member_only
|
||||
|
||||
def index
|
||||
@anti_voters = AntiVoter.all
|
||||
end
|
||||
end
|
||||
|
@ -16,5 +16,6 @@ class DailyMaintenance
|
||||
PostDisapproval.dmail_messages!
|
||||
Tag.clean_up_negative_post_counts!
|
||||
SuperVoter.init!
|
||||
AntiVote.init!
|
||||
end
|
||||
end
|
||||
|
34
app/models/anti_voter.rb
Normal file
34
app/models/anti_voter.rb
Normal file
@ -0,0 +1,34 @@
|
||||
class AntiVoter < ActiveRecord::Base
|
||||
MAGNITUDE = 3
|
||||
DURATION = 1.week
|
||||
|
||||
belongs_to :user
|
||||
validates_uniqueness_of :user_id
|
||||
# after_create :update_user_on_create
|
||||
# after_destroy :update_user_on_destroy
|
||||
|
||||
def self.prune!
|
||||
where("created_at < ?", DURATION.ago).destroy_all
|
||||
end
|
||||
|
||||
def self.init!
|
||||
prune!
|
||||
report = PostVoteSimilarity.new(User.admins.first.id)
|
||||
|
||||
report.calculate_negative.each do |element|
|
||||
unless where("user_id = ?", element.user_id).exists?
|
||||
create(:user_id => element.user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# def update_user_on_create
|
||||
# user.is_super_voter = true
|
||||
# user.save
|
||||
# end
|
||||
|
||||
# def update_user_on_destroy
|
||||
# user.is_super_voter = false
|
||||
# user.save
|
||||
# end
|
||||
end
|
15
app/views/anti_voters/index.html.erb
Normal file
15
app/views/anti_voters/index.html.erb
Normal file
@ -0,0 +1,15 @@
|
||||
<div id="c-super-voters">
|
||||
<div id="a-index">
|
||||
<h1>Anti Voters</h1>
|
||||
|
||||
<ul>
|
||||
<% @anti_voters.each do |anti_voter| %>
|
||||
<li><%= link_to_if CurrentUser.user.is_janitor?, anti_voter.user.name, posts_path(tags: "upvote:#{anti_voter.user.name}") %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Anti Voters - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
8
db/migrate/20160919234407_create_anti_voters.rb
Normal file
8
db/migrate/20160919234407_create_anti_voters.rb
Normal file
@ -0,0 +1,8 @@
|
||||
class CreateAntiVoters < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :anti_voters do |t|
|
||||
t.integer :user_id
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user