Class: Admin::BizProcessesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::BizProcessesController
- Includes:
- BizProcessesHelper, AutofilterHelper, ManyHelper
- Defined in:
- app/controllers/admin/biz_processes_controller.rb
Instance Method Summary (collapse)
- - (Object) add_person
-
- (Object) controls
Many2many relationship to Controls - show / update.
-
- (Object) create
Create a biz process.
-
- (Object) create_person
Another way to attach a biz process.
-
- (Object) destroy
Delete biz process.
-
- (Object) destroy_person
Another way to detach a biz process.
-
- (Object) edit
Show edit biz process form.
-
- (Object) index
List all biz processes.
-
- (Object) new
Show new biz process form.
-
- (Object) show
Show one biz process.
-
- (Object) systems
Many2many relationship to Systems - show / update.
-
- (Object) update
Update a biz process.
Methods included from AutofilterHelper
#filtered_controls, #filtered_sections
Methods included from ManyHelper
#edit_children, #edit_children_inline, #edit_many, #edit_many_anon, #edit_many_attach, #get_many2many, #post_many2many
Instance Method Details
- (Object) add_person
145 146 147 |
# File 'app/controllers/admin/biz_processes_controller.rb', line 145 def add_person @biz_process = BizProcess.find(params[:id]) end |
- (Object) controls
Many2many relationship to Controls - show / update
128 129 130 131 132 133 134 |
# File 'app/controllers/admin/biz_processes_controller.rb', line 128 def controls if request.put? post_many2many(:left_class => BizProcess, :right_class => Control) else get_many2many(:left_class => BizProcess, :right_class => Control) end end |
- (Object) create
Create a biz process
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/admin/biz_processes_controller.rb', line 43 def create @biz_process = BizProcess.new # Attach biz process to any related objects specified by the user (Controls, COs, Systems) update_biz_process_relations(@biz_process, params[:biz_process]) @biz_process.attributes = params[:biz_process] respond_to do |format| if @biz_process.save format.html { redirect_to(edit_biz_process_path(@biz_process), :notice => 'Biz Process was successfully created.') } format.xml { render :xml => @biz_process, :status => :created, :location => @biz_process } else flash.now[:error] = "Could not create." format.html { render :action => "new" } format.xml { render :xml => @biz_process.errors, :status => :unprocessable_entity } end end end |
- (Object) create_person
Another way to attach a biz process
150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'app/controllers/admin/biz_processes_controller.rb', line 150 def create_person @biz_process = BizProcess.find(params[:id]) @biz_process_person = BizProcessPerson.new(params[:biz_process_person]) @biz_process_person.biz_process = @biz_process if @biz_process_person.save flash[:notice] = 'Contact was successfully attached.' redirect_to edit_biz_process_path(@biz_process) else flash[:error] = 'Failed' + @biz_process_person.errors.inspect redirect_to add_person_biz_process_path(@biz_process_person.person) end end |
- (Object) destroy
Delete biz process
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'app/controllers/admin/biz_processes_controller.rb', line 111 def destroy biz_process = BizProcess.find(params[:id]) # Delete links to other objects first, then delete the biz process success = biz_process && biz_process.biz_process_systems.destroy && biz_process.biz_process_controls.destroy && biz_process.biz_process_sections.destroy && biz_process.biz_process_documents.destroy && biz_process.destroy respond_to do |format| format.html { redirect_to(biz_processes_url) } format.xml { head :ok } end end |
- (Object) destroy_person
Another way to detach a biz process
164 165 166 167 168 169 170 171 172 |
# File 'app/controllers/admin/biz_processes_controller.rb', line 164 def destroy_person bpp = BizProcessPerson.first(:person_id => params[:person_id], :biz_process_id => params[:id]) if bpp && bpp.destroy flash[:notice] = 'Contact was successfully detached.' else flash[:error] = 'Failed' end redirect_to edit_biz_process_path(BizProcess.find(params[:id])) end |
- (Object) edit
Show edit biz process form
38 39 40 |
# File 'app/controllers/admin/biz_processes_controller.rb', line 38 def edit @biz_process = BizProcess.find(params[:id]) end |
- (Object) index
List all biz processes
8 9 10 11 12 13 14 15 |
# File 'app/controllers/admin/biz_processes_controller.rb', line 8 def index @biz_processes = BizProcess.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @biz_processes } end end |
- (Object) new
Show new biz process form
28 29 30 31 32 33 34 35 |
# File 'app/controllers/admin/biz_processes_controller.rb', line 28 def new @biz_process = BizProcess.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @biz_process } end end |
- (Object) show
Show one biz process
18 19 20 21 22 23 24 25 |
# File 'app/controllers/admin/biz_processes_controller.rb', line 18 def show @biz_process = BizProcess.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @biz_process } end end |
- (Object) systems
Many2many relationship to Systems - show / update
137 138 139 140 141 142 143 |
# File 'app/controllers/admin/biz_processes_controller.rb', line 137 def systems if request.put? post_many2many(:left_class => BizProcess, :right_class => System) else get_many2many(:left_class => BizProcess, :right_class => System) end end |
- (Object) update
Update a biz process
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'app/controllers/admin/biz_processes_controller.rb', line 64 def update @biz_process = BizProcess.find(params[:id]) # Accumulate DB update results results = [] # Attach biz process to any related objects specified by the user (Controls, COs, Systems) update_biz_process_relations(@biz_process, params[:biz_process]) # Update linked policy documents (params[:policies] || {}).each_pair do |index, doc_params| next if doc_params["link"].blank? is_delete = doc_params.delete("delete") == "1" id = doc_params.delete("id") if id.blank? # No existing doc id - create the doc doc = @biz_process.policies.create(doc_params) results << doc elsif is_delete # Delete checkbox was on results << @biz_process.biz_process_documents.first(:policy_id => id).destroy results << Document.first(:id => id).destroy else # Otherwise, update results << Document.find(id).update_attributes(doc_params) end end # Save if any changes made above @biz_process.save if @biz_process.changed? results << @biz_process.update_attributes(params[:biz_process]) respond_to do |format| # If all operations above succeeded, show overall success, otherwise show errors if results.all? format.html { redirect_to(edit_biz_process_path(@biz_process), :notice => 'Biz Process was successfully updated.') } format.xml { head :ok } else flash.now[:error] = "Could not update." format.html { render :action => "edit" } format.xml { render :xml => @biz_process.errors, :status => :unprocessable_entity } end end end |