Fix #3534: Remove Janitor Trials.
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
class JanitorTrialsController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
before_action :moderator_only, :only => [:create, :promote, :demote]
|
||||
|
||||
def new
|
||||
@janitor_trial = JanitorTrial.new
|
||||
respond_with(@janitor_trial)
|
||||
end
|
||||
|
||||
def edit
|
||||
@janitor_trial = JanitorTrial.find(params[:id])
|
||||
respond_with(@janitor_trial)
|
||||
end
|
||||
|
||||
def index
|
||||
@janitor_trials = JanitorTrial.paginated_search(params)
|
||||
respond_with(@janitor_trials)
|
||||
end
|
||||
|
||||
def create
|
||||
@janitor_trial = JanitorTrial.create(janitor_trial_params)
|
||||
respond_with(@janitor_trial, :location => janitor_trials_path)
|
||||
end
|
||||
|
||||
def promote
|
||||
@janitor_trial = JanitorTrial.find(params[:id])
|
||||
@janitor_trial.promote!
|
||||
respond_with(@janitor_trial) do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def demote
|
||||
@janitor_trial = JanitorTrial.find(params[:id])
|
||||
@janitor_trial.demote!
|
||||
respond_with(@janitor_trial) do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def test
|
||||
@tester = JanitorTrialTester.new(params[:janitor_trial][:user_name])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def janitor_trial_params
|
||||
params.require(:janitor_trial).permit(%i[user_id user_name])
|
||||
end
|
||||
end
|
||||
@@ -1,29 +0,0 @@
|
||||
let JanitorTrials = {};
|
||||
|
||||
JanitorTrials.initialize_all = function() {
|
||||
if ($("#c-janitor-trials").length) {
|
||||
$("input[value=Test]").on("click.danbooru", function(e) {
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "/janitor_trials/test.json",
|
||||
data: {
|
||||
janitor_trial: {
|
||||
user_name: $("#janitor_trial_user_name").val()
|
||||
}
|
||||
},
|
||||
success: function(data) {
|
||||
$("#test-results").html(data);
|
||||
}
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
JanitorTrials.initialize_all();
|
||||
});
|
||||
|
||||
export default JanitorTrials
|
||||
@@ -13,15 +13,9 @@ module ApproverPruner
|
||||
CurrentUser.scoped(User.system, "127.0.0.1") do
|
||||
next if user.is_admin?
|
||||
|
||||
janitor_trial = JanitorTrial.where(user_id: user.id).first
|
||||
user.update!(can_approve_posts: false)
|
||||
user.feedback.create(category: "neutral", body: "Lost approval privileges")
|
||||
|
||||
if janitor_trial && user.can_approve_posts?
|
||||
janitor_trial.demote!
|
||||
else
|
||||
user.can_approve_posts = false
|
||||
user.save
|
||||
end
|
||||
|
||||
Dmail.create_automated(
|
||||
:to_id => user.id,
|
||||
:title => "Approver inactivity",
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
class JanitorTrialTester
|
||||
attr_reader :user
|
||||
|
||||
def initialize(user_name)
|
||||
@user = User.find_by_name(user_name)
|
||||
end
|
||||
|
||||
def test
|
||||
if user.nil?
|
||||
"User not found"
|
||||
elsif user.created_at > 1.month.ago
|
||||
"User signed up within the past month"
|
||||
elsif user.favorites.count < 100
|
||||
"User has fewer than 100 favorites"
|
||||
elsif user.feedback.negative.count > 0
|
||||
"User has negative feedback"
|
||||
else
|
||||
"No issues found"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,65 +0,0 @@
|
||||
class JanitorTrial < ApplicationRecord
|
||||
belongs_to :user
|
||||
after_create :send_dmail
|
||||
after_create :promote_user
|
||||
belongs_to_creator
|
||||
validates_inclusion_of :status, :in => %w(active inactive)
|
||||
before_validation :initialize_status
|
||||
validates_uniqueness_of :user_id
|
||||
|
||||
def self.search(params)
|
||||
q = super.where(status: "active")
|
||||
q = q.search_attributes(params, :user, :creator, :original_level)
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
|
||||
def initialize_status
|
||||
self.status = "active"
|
||||
end
|
||||
|
||||
def user_name
|
||||
user.try(:name)
|
||||
end
|
||||
|
||||
def user_name=(name)
|
||||
self.user = User.find_by_name(name)
|
||||
end
|
||||
|
||||
def send_dmail
|
||||
body = "You have been selected as a test janitor. You can now approve pending posts and have access to the moderation interface. You should reacquaint yourself with the [[howto:upload]] guide to make sure you understand the site rules.\n\nOver the next several weeks your approvals will be monitored. If the majority of them are not quality uploads you will fail the trial period and lose your approval privileges. You will also receive a negative user record indicating you previously attempted and failed a test janitor trial.\n\nThere is a minimum quota of 1 approval a month to indicate that you are being active. Remember, the goal isn't to approve as much as possible. It's to filter out borderline-quality art."
|
||||
|
||||
Dmail.create_automated(:title => "Test Janitor Trial Period", :body => body, :to_id => user_id)
|
||||
end
|
||||
|
||||
def promote_user
|
||||
user.feedback.create(:category => "neutral", :body => "Gained approval privileges")
|
||||
user.can_approve_posts = true
|
||||
user.save
|
||||
end
|
||||
|
||||
def create_feedback
|
||||
user.feedback.create(
|
||||
:category => "neutral",
|
||||
:body => "Lost approval privileges"
|
||||
)
|
||||
end
|
||||
|
||||
def promote!
|
||||
update_attribute(:status, "inactive")
|
||||
end
|
||||
|
||||
def demote!
|
||||
user.can_approve_posts = false
|
||||
user.save
|
||||
update_attribute(:status, "inactive")
|
||||
self.create_feedback
|
||||
end
|
||||
|
||||
def active?
|
||||
status == "active"
|
||||
end
|
||||
|
||||
def inactive?
|
||||
status == "inactive"
|
||||
end
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<%= subnav_link_to "Listing", janitor_trials_path %>
|
||||
<%= subnav_link_to "New", new_janitor_trial_path %>
|
||||
<% end %>
|
||||
@@ -1 +0,0 @@
|
||||
location.reload();
|
||||
@@ -1,29 +0,0 @@
|
||||
<div id="c-janitor-trials">
|
||||
<div id="a-index">
|
||||
<h1>Janitor Trials</h1>
|
||||
|
||||
<table class="striped" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Date</th>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @janitor_trials.each do |janitor_trial| %>
|
||||
<tr>
|
||||
<td><%= link_to_user janitor_trial.user %></td>
|
||||
<td><%= compact_time janitor_trial.created_at %></td>
|
||||
<td>
|
||||
<%= link_to "Promote", promote_janitor_trial_path(janitor_trial), :remote => true, :method => :put %>
|
||||
| <%= link_to "Demote", demote_janitor_trial_path(janitor_trial), :remote => true, :method => :put %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
@@ -1,17 +0,0 @@
|
||||
<div id="c-janitor-trials">
|
||||
<div id="a-new">
|
||||
<h1>New Janitor Trial</h1>
|
||||
|
||||
<%= error_messages_for :janitor_trial %>
|
||||
|
||||
<%= simple_form_for(@janitor_trial) do |f| %>
|
||||
<%= f.input :user_name, input_html: { data: { autocomplete: "user" } } %>
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<%= f.button :submit, "Test" %>
|
||||
<% end %>
|
||||
|
||||
<p id="test-results"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
@@ -1 +0,0 @@
|
||||
location.reload();
|
||||
@@ -1 +0,0 @@
|
||||
<%= raw @tester.test.to_json %>
|
||||
@@ -151,7 +151,6 @@
|
||||
<li><%= link_to("Mod Actions", mod_actions_path) %></li>
|
||||
<li><%= link_to("Jobs", delayed_jobs_path) %></li>
|
||||
<li><%= link_to("Bulk Update Requests", bulk_update_requests_path) %></li>
|
||||
<li><%= link_to("Janitor Trials", janitor_trials_path) %></li>
|
||||
|
||||
<% if CurrentUser.is_member? %>
|
||||
<li><%= link_to("User Name Change Requests", user_name_change_requests_path) %></li>
|
||||
|
||||
Reference in New Issue
Block a user