some fixes to janitor trials, implemented jan trial controller test
This commit is contained in:
@@ -1,19 +1,36 @@
|
||||
class JanitorTrialsController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
def show
|
||||
@search = JanitorTrial.search(params[:search])
|
||||
@janitor_trials = @search.paginate(:page => params[:page])
|
||||
respond_with(@janitor_trials)
|
||||
end
|
||||
|
||||
def create
|
||||
@janitor_trial = JanitorTrial.create(params[:janitor_trial])
|
||||
respond_with(@janitor_trial)
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
def promote
|
||||
@janitor_trial = JanitorTrial.find(params[:id])
|
||||
@janitor_trial.promote!
|
||||
respond_with(@janitor_trial)
|
||||
end
|
||||
|
||||
def demote
|
||||
@janitor_trial = JanitorTrial.find(params[:id])
|
||||
@janitor_trial.demote!
|
||||
respond_with(@janitor_trial)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,33 @@
|
||||
class JanitorTrial < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
after_create :send_dmail
|
||||
after_create :promote_user
|
||||
after_destroy :create_feedback
|
||||
validates_presence_of :user
|
||||
|
||||
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.\n\nOver the next several weeks your approvals will be monitored. If the majority of them are quality uploads, then you will be promoted to full janitor status which grants you the ability to delete and undelete posts, ban users, and revert tag changes from vandals. If you fail the trial period, you will be demoted back to your original level and you'll receive a negative user record indicating you previously attempted and failed a test janitor trial.\n\nThere is a minimum quota of 5 approvals a week 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.\n\nIf you have any questions please respond to this message."
|
||||
|
||||
Dmail.create_split(:title => "Test Janitor Trial Period", :body => body, :to_id => user_id)
|
||||
end
|
||||
|
||||
def promote_user
|
||||
user.update_attribute(:is_janitor, true)
|
||||
end
|
||||
|
||||
def create_feedback
|
||||
user.feedback.create(
|
||||
:is_positive => false,
|
||||
:body => "Demoted from janitor trial"
|
||||
)
|
||||
end
|
||||
|
||||
def promote!
|
||||
destroy
|
||||
end
|
||||
|
||||
def demote!
|
||||
user.update_attribute(:is_janitor, false)
|
||||
destroy
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,10 +2,15 @@ class UserFeedback < ActiveRecord::Base
|
||||
set_table_name "user_feedback"
|
||||
belongs_to :user
|
||||
belongs_to :creator, :class_name => "User"
|
||||
before_validation :initialize_creator, :on => :create
|
||||
attr_accessible :body, :user_id, :is_positive
|
||||
validates_presence_of :user_id, :creator_id, :body
|
||||
validates_presence_of :user, :creator, :body
|
||||
validate :creator_is_privileged
|
||||
|
||||
def initialize_creator
|
||||
self.creator_id = CurrentUser.id
|
||||
end
|
||||
|
||||
def creator_is_privileged
|
||||
if !creator.is_privileged?
|
||||
errors[:creator] << "must be privileged"
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<h1>IP Bans</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>IP Address</th>
|
||||
<th>Banner</th>
|
||||
<th>Reason</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @ip_bans.each do |ip_ban| %>
|
||||
<tr>
|
||||
<td><%= ip_ban.ip_addr %></td>
|
||||
<td><%= ip_ban.creator.name %></td>
|
||||
<td><%= ip_ban.reason %></td>
|
||||
<td><%= link_to "Unban", ip_ban_path(ip_ban), :remote => true, :method => :delete, :confirm => "Do your really want to unban #{ip_ban.creator.name}?" %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<h1>New IP Ban</h1>
|
||||
|
||||
<%= simple_form_for(@ip_ban) do |f| %>
|
||||
<%= f.input :ip_addr %>
|
||||
<%= f.input :reason %>
|
||||
<%= f.button :submit %>
|
||||
<% end %>
|
||||
|
||||
0
app/views/janitor_trials/edit.html.erb
Normal file
0
app/views/janitor_trials/edit.html.erb
Normal file
0
app/views/janitor_trials/index.html.erb
Normal file
0
app/views/janitor_trials/index.html.erb
Normal file
0
app/views/janitor_trials/new.html.erb
Normal file
0
app/views/janitor_trials/new.html.erb
Normal file
Reference in New Issue
Block a user