From f79e0d6e06520ac898220af7d667d20767f36c4f Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Thu, 22 Jun 2017 11:03:56 -0500 Subject: [PATCH] add reason field to source suggestion updates --- app/controllers/sources_controller.rb | 2 +- app/presenters/source_suggestion_browse_row_presenter.rb | 3 ++- .../20170622160223_add_reason_field_to_source_suggestion.rb | 5 +++++ db/structure.sql | 5 ++++- 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20170622160223_add_reason_field_to_source_suggestion.rb diff --git a/app/controllers/sources_controller.rb b/app/controllers/sources_controller.rb index 6a86a416..10884d59 100644 --- a/app/controllers/sources_controller.rb +++ b/app/controllers/sources_controller.rb @@ -75,7 +75,7 @@ def update end def update_source_suggestion - status = params.permit(:status) + status = params.permit(:status, :reason) suggestion = SourceSuggestion.find_by(id: params[:id]) authorize suggestion if suggestion.update_attributes(status) diff --git a/app/presenters/source_suggestion_browse_row_presenter.rb b/app/presenters/source_suggestion_browse_row_presenter.rb index 61e4cda9..33a54d10 100644 --- a/app/presenters/source_suggestion_browse_row_presenter.rb +++ b/app/presenters/source_suggestion_browse_row_presenter.rb @@ -19,7 +19,8 @@ def as_json(opts = {}) disease: suggestion.disease_name, initial_comment: suggestion.initial_comment, status: suggestion.status, - created_at: suggestion.created_at + created_at: suggestion.created_at, + reason: suggestion.reason } end end diff --git a/db/migrate/20170622160223_add_reason_field_to_source_suggestion.rb b/db/migrate/20170622160223_add_reason_field_to_source_suggestion.rb new file mode 100644 index 00000000..0f5f2839 --- /dev/null +++ b/db/migrate/20170622160223_add_reason_field_to_source_suggestion.rb @@ -0,0 +1,5 @@ +class AddReasonFieldToSourceSuggestion < ActiveRecord::Migration + def change + add_column :source_suggestions, :reason, :text + end +end diff --git a/db/structure.sql b/db/structure.sql index 73b159cc..4bacde21 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1136,7 +1136,8 @@ CREATE TABLE source_suggestions ( initial_comment text, status text, created_at timestamp without time zone, - updated_at timestamp without time zone + updated_at timestamp without time zone, + reason text ); @@ -3259,3 +3260,5 @@ INSERT INTO schema_migrations (version) VALUES ('20170531193921'); INSERT INTO schema_migrations (version) VALUES ('20170609200608'); +INSERT INTO schema_migrations (version) VALUES ('20170622160223'); +