Class: ScaptimonyPoliciesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ScaptimonyPoliciesController
- Includes:
- Foreman::Controller::AutoCompleteSearch
- Defined in:
- app/controllers/scaptimony_policies_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #model_of_controller ⇒ Object
- #new ⇒ Object
- #parse ⇒ Object
- #scap_content_selected ⇒ Object
- #select_multiple_hosts ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #update_multiple_hosts ⇒ Object
- #welcome ⇒ Object
Instance Method Details
#create ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 31 def create @policy = ::Scaptimony::Policy.new(params[:policy]) if @policy.wizard_completed? && @policy.save process_success :success_redirect => scaptimony_policies_path else if @policy.valid? render 'new' and return else @policy.rewind_step process_error :object => @policy end end end |
#destroy ⇒ Object
56 57 58 59 60 61 62 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 56 def destroy if @policy.destroy process_success else process_error :object => @policy end end |
#edit ⇒ Object
45 46 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 45 def edit end |
#index ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 10 def index @policies = resource_base .search_for(params[:search], :order => params[:order]) .paginate(:page => params[:page], :per_page => params[:per_page]) .includes(:scap_content, :scap_content_profile) if @policies.empty? && Scaptimony::ScapContent.unconfigured? redirect_to scaptimony_scap_contents_path end end |
#model_of_controller ⇒ Object
6 7 8 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 6 def model_of_controller ::Scaptimony::Policy end |
#new ⇒ Object
20 21 22 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 20 def new @policy = ::Scaptimony::Policy.new end |
#parse ⇒ Object
27 28 29 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 27 def parse self.response_body = @policy.to_html end |
#scap_content_selected ⇒ Object
64 65 66 67 68 69 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 64 def scap_content_selected if params[:scap_content_id] && (@scap_content = ::Scaptimony::ScapContent.find(params[:scap_content_id])) @policy ||= ::Scaptimony::Policy.new render :partial => 'scap_content_results', :locals => {:policy => @policy} end end |
#select_multiple_hosts ⇒ Object
71 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 71 def select_multiple_hosts; end |
#show ⇒ Object
24 25 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 24 def show end |
#update ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 48 def update if @policy.update_attributes(params[:policy]) process_success :success_redirect => scaptimony_policies_path else process_error :object => @policy end end |
#update_multiple_hosts ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 73 def update_multiple_hosts if (id = params['policy']['id']) policy = ::Scaptimony::Policy.find(id) policy.assign_hosts @hosts notice _("Updated hosts: Assigned with compliance policy: #{policy.name}") # We prefer to go back as this does not lose the current search redirect_to hosts_path else error _('No compliance policy selected.') redirect_to(select_multiple_hosts_scaptimony_policies_path) end end |
#welcome ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'app/controllers/scaptimony_policies_controller.rb', line 86 def welcome @searchbar = true if (model_of_controller.first.nil? rescue false) @searchbar = false render :welcome rescue nil and return end rescue not_found end |