From b2684a2c3ec023f419eb92b30102f2308dbc01c2 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 1 Aug 2013 19:21:46 +0100 Subject: Move outgoing message admin actions to their own controller. Eventually this should use standard RESTful routing. --- .../admin_outgoing_message_controller.rb | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 app/controllers/admin_outgoing_message_controller.rb (limited to 'app/controllers/admin_outgoing_message_controller.rb') diff --git a/app/controllers/admin_outgoing_message_controller.rb b/app/controllers/admin_outgoing_message_controller.rb new file mode 100644 index 000000000..3f53838d6 --- /dev/null +++ b/app/controllers/admin_outgoing_message_controller.rb @@ -0,0 +1,36 @@ +class AdminOutgoingMessageController < AdminController + + def edit + @outgoing_message = OutgoingMessage.find(params[:id]) + end + + def destroy + @outgoing_message = OutgoingMessage.find(params[:outgoing_message_id]) + @info_request = @outgoing_message.info_request + outgoing_message_id = @outgoing_message.id + + @outgoing_message.fully_destroy + @outgoing_message.info_request.log_event("destroy_outgoing", + { :editor => admin_current_user(), :deleted_outgoing_message_id => outgoing_message_id }) + + flash[:notice] = 'Outgoing message successfully destroyed.' + redirect_to admin_request_show_url(@info_request) + end + + def update + @outgoing_message = OutgoingMessage.find(params[:id]) + + old_body = @outgoing_message.body + + if @outgoing_message.update_attributes(params[:outgoing_message]) + @outgoing_message.info_request.log_event("edit_outgoing", + { :outgoing_message_id => @outgoing_message.id, :editor => admin_current_user(), + :old_body => old_body, :body => @outgoing_message.body }) + flash[:notice] = 'Outgoing message successfully updated.' + redirect_to admin_request_show_url(@outgoing_message.info_request) + else + render :action => 'edit' + end + end + +end -- cgit v1.2.3 From ca294ea3cbcc90851bed388a8b5449f81eafa32d Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 27 Aug 2013 12:55:25 +0100 Subject: Add prominence fields and cache expiry to outgoing admin --- app/controllers/admin_outgoing_message_controller.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'app/controllers/admin_outgoing_message_controller.rb') diff --git a/app/controllers/admin_outgoing_message_controller.rb b/app/controllers/admin_outgoing_message_controller.rb index 3f53838d6..ec0981677 100644 --- a/app/controllers/admin_outgoing_message_controller.rb +++ b/app/controllers/admin_outgoing_message_controller.rb @@ -21,12 +21,23 @@ class AdminOutgoingMessageController < AdminController @outgoing_message = OutgoingMessage.find(params[:id]) old_body = @outgoing_message.body - - if @outgoing_message.update_attributes(params[:outgoing_message]) + old_prominence = @outgoing_message.prominence + old_prominence_reason = @outgoing_message.prominence_reason + @outgoing_message.prominence = params[:outgoing_message][:prominence] + @outgoing_message.prominence_reason = params[:outgoing_message][:prominence_reason] + @outgoing_message.body = params[:outgoing_message][:body] + if @outgoing_message.save @outgoing_message.info_request.log_event("edit_outgoing", - { :outgoing_message_id => @outgoing_message.id, :editor => admin_current_user(), - :old_body => old_body, :body => @outgoing_message.body }) + { :outgoing_message_id => @outgoing_message.id, + :editor => admin_current_user(), + :old_body => old_body, + :body => @outgoing_message.body, + :old_prominence => old_prominence, + :old_prominence_reason => old_prominence_reason, + :prominence => @outgoing_message.prominence, + :prominence_reason => @outgoing_message.prominence_reason }) flash[:notice] = 'Outgoing message successfully updated.' + expire_for_request(@outgoing_message.info_request) redirect_to admin_request_show_url(@outgoing_message.info_request) else render :action => 'edit' -- cgit v1.2.3