ref: master
app/controllers/admin/region_validators_controller.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
class RegionValidatorsController < AdminController before_filter :load_region_and_search, :except => 'index' protect 'manage_environment_validators', :environment def index @regions = Region.top_level_for(environment) end def region # nothing to do, load_region_and_search already does everything needed here end def search render :partial => 'search' end def add validator = environment.organizations.find(params[:validator_id]) @region.validators << validator redirect_to :action => 'region', :id => @region.id end def remove validator = environment.organizations.find(params[:validator_id]) @region.validators.delete(validator) redirect_to :action => 'region', :id => @region.id end protected def load_region_and_search @region = environment.regions.find(params[:id]) if params[:search] @search = find_by_contents(:organizations, environment, Organization, params[:search])[:results].reject {|item| @region.validator_ids.include?(item.id) } end end end |