aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/admin_public_body_controller.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-01-28 16:56:32 +0000
committerLouise Crow <louise.crow@gmail.com>2014-01-28 16:56:32 +0000
commitfc0c4ea6fa66dc2cbd839de013476205bf574c90 (patch)
tree676a51352756ba91f7c676db2d1225400f010a47 /app/controllers/admin_public_body_controller.rb
parent89a8fd2ce9880ae0f194733991aa93e447f0ba73 (diff)
parent0299747af77b5a7c870c31a99598ff1d2928b507 (diff)
Merge branch 'feature/1176-automate-authority-contacts' into rails-3-develop
Conflicts: doc/CHANGES.md
Diffstat (limited to 'app/controllers/admin_public_body_controller.rb')
-rw-r--r--app/controllers/admin_public_body_controller.rb42
1 files changed, 39 insertions, 3 deletions
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb
index 88e275960..120419a27 100644
--- a/app/controllers/admin_public_body_controller.rb
+++ b/app/controllers/admin_public_body_controller.rb
@@ -85,14 +85,33 @@ class AdminPublicBodyController < AdminController
def new
@public_body = PublicBody.new
- render
+ if params[:change_request_id]
+ @change_request = PublicBodyChangeRequest.find(params[:change_request_id])
+ end
+ if @change_request
+ @change_request_user_response = render_to_string(:template => "admin_public_body_change_requests/add_accepted",
+ :formats => [:txt])
+ @public_body.name = @change_request.public_body_name
+ @public_body.request_email = @change_request.public_body_email
+ @public_body.last_edit_comment = @change_request.comment_for_public_body
+ end
+ render :formats => [:html]
end
def create
I18n.with_locale(I18n.default_locale) do
+ if params[:change_request_id]
+ @change_request = PublicBodyChangeRequest.find(params[:change_request_id])
+ end
params[:public_body][:last_edit_editor] = admin_current_user()
@public_body = PublicBody.new(params[:public_body])
if @public_body.save
+ if @change_request
+ response_text = params[:response].gsub(_("[Authority URL will be inserted here]"),
+ public_body_url(@public_body, :only_path => false))
+ @change_request.close!
+ @change_request.send_response(params[:subject], response_text)
+ end
flash[:notice] = 'PublicBody was successfully created.'
redirect_to admin_body_show_url(@public_body)
else
@@ -103,15 +122,32 @@ class AdminPublicBodyController < AdminController
def edit
@public_body = PublicBody.find(params[:id])
- @public_body.last_edit_comment = ""
- render
+ if params[:change_request_id]
+ @change_request = PublicBodyChangeRequest.find(params[:change_request_id])
+ end
+ if @change_request
+ @change_request_user_response = render_to_string(:template => "admin_public_body_change_requests/update_accepted",
+ :formats => [:txt])
+ @public_body.request_email = @change_request.public_body_email
+ @public_body.last_edit_comment = @change_request.comment_for_public_body
+ else
+ @public_body.last_edit_comment = ""
+ end
+ render :formats => [:html]
end
def update
+ if params[:change_request_id]
+ @change_request = PublicBodyChangeRequest.find(params[:change_request_id])
+ end
I18n.with_locale(I18n.default_locale) do
params[:public_body][:last_edit_editor] = admin_current_user()
@public_body = PublicBody.find(params[:id])
if @public_body.update_attributes(params[:public_body])
+ if @change_request
+ @change_request.close!
+ @change_request.send_response(params[:subject], params[:response])
+ end
flash[:notice] = 'PublicBody was successfully updated.'
redirect_to admin_body_show_url(@public_body)
else