@@ -12,7 +12,7 @@ def admin_create
1212 if @section . save
1313 @section . phase . template . dirty = true
1414 @section . phase . template . save!
15-
15+
1616 redirect_to admin_show_phase_path ( id : @section . phase_id ,
1717 :section_id => @section . id , edit : 'true' ) , notice : _ ( 'Information was successfully created.' )
1818 else
@@ -22,6 +22,11 @@ def admin_create
2222 @section_id = @section . id
2323 @question_id = nil
2424 flash [ :notice ] = failed_create_error ( @section , _ ( 'section' ) )
25+ if @phase . template . customization_of . present?
26+ @original_org = Template . where ( dmptemplate_id : @phase . template . customization_of ) . first . org
27+ else
28+ @original_org = @phase . template . org
29+ end
2530 render template : 'phases/admin_show'
2631 end
2732 end
@@ -36,7 +41,7 @@ def admin_update
3641 if @section . update_attributes ( params [ :section ] )
3742 @section . phase . template . dirty = true
3843 @section . phase . template . save!
39-
44+
4045 redirect_to admin_show_phase_path ( id : @phase . id , section_id : @section . id , edit : 'true' ) , notice : _ ( 'Information was successfully updated.' )
4146 else
4247 @edit = ( @phase . template . org == current_user . org )
@@ -45,6 +50,11 @@ def admin_update
4550 @section_id = @section . id
4651 @question_id = nil
4752 flash [ :notice ] = failed_update_error ( @section , _ ( 'section' ) )
53+ if @phase . template . customization_of . present?
54+ @original_org = Template . where ( dmptemplate_id : @phase . template . customization_of ) . first . org
55+ else
56+ @original_org = @phase . template . org
57+ end
4858 render template : 'phases/admin_show'
4959 end
5060 end
@@ -55,22 +65,27 @@ def admin_destroy
5565 @section = Section . includes ( phase : :template ) . find ( params [ :section_id ] )
5666 authorize @section
5767 @phase = @section . phase
58-
68+
5969 if @section . destroy
6070 @phase . template . dirty = true
6171 @phase . template . save!
62-
72+
6373 redirect_to admin_show_phase_path ( id : @phase . id , edit : 'true' ) , notice : _ ( 'Information was successfully deleted.' )
6474 else
6575 @edit = ( @phase . template . org == current_user . org )
6676 @open = true
6777 @sections = @phase . sections
6878 @section_id = @section . id
6979 @question_id = nil
70-
80+
7181 flash [ :notice ] = failed_destroy_error ( @section , _ ( 'section' ) )
82+ if @phase . template . customization_of . present?
83+ @original_org = Template . where ( dmptemplate_id : @phase . template . customization_of ) . first . org
84+ else
85+ @original_org = @phase . template . org
86+ end
7287 render template : 'phases/admin_show'
7388 end
7489 end
75-
90+
7691end
0 commit comments