bulk revert
This commit is contained in:
@@ -1,24 +1,35 @@
|
||||
module Moderator
|
||||
class BulkRevertsController < ApplicationController
|
||||
before_filter :moderator_only
|
||||
before_filter :init_constraints
|
||||
helper PostVersionsHelper
|
||||
rescue_from BulkRevert::ConstraintTooGeneralError, :with => :tag_constraint_too_general
|
||||
|
||||
def new
|
||||
@constraints = params[:constraints] || {}
|
||||
end
|
||||
|
||||
def create
|
||||
@constraints = params[:constraints] || {}
|
||||
@bulk_revert = BulkRevert.new(@constraints)
|
||||
|
||||
if params[:commit] == "Test"
|
||||
@bulk_revert.preview
|
||||
render action: "new"
|
||||
else
|
||||
@bulk_revert.process!
|
||||
BulkRevert.delay(:queue => "default").process(@constraints)
|
||||
flash[:notice] = "Reverts queued"
|
||||
redirect_to new_bulk_revert_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def init_constraints
|
||||
@constraints = params[:constraints] || {}
|
||||
end
|
||||
|
||||
def tag_constraint_too_general
|
||||
flash[:notice] = "Your tag constraints are too general; try adding min and max version ids"
|
||||
render action: "new"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user