aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/admin_public_body_controller.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-03-04 10:46:46 +0000
committerLouise Crow <louise.crow@gmail.com>2014-03-04 10:46:46 +0000
commitede46dc8dc6c97cdad8c3fcb3bd42ede5c25f395 (patch)
tree44e03358c9fa7ca6826e631d1d3d6c1030b1b0d5 /app/controllers/admin_public_body_controller.rb
parent8e911d5bd0e60a0e0e4859868662cc176419d2e3 (diff)
parenta38b2989aebf8d554b7287e18528bed8c9e67d3b (diff)
Merge branch 'release/0.17'0.17
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