From d280c254c88fc9c48056e7e9743c7de4f8f64003 Mon Sep 17 00:00:00 2001
From: Bertocq
Date: Mon, 29 Jan 2018 21:15:28 +0100
Subject: [PATCH 1/3] Remove usage of Investment's internal_comments attr
---
app/controllers/valuation/budget_investments_controller.rb | 2 +-
.../budget_investments/_written_by_valuators.html.erb | 4 ----
app/views/valuation/budget_investments/edit.html.erb | 7 -------
config/locales/en/valuation.yml | 2 --
config/locales/es/valuation.yml | 2 --
spec/features/valuation/budget_investments_spec.rb | 6 +-----
6 files changed, 2 insertions(+), 21 deletions(-)
diff --git a/app/controllers/valuation/budget_investments_controller.rb b/app/controllers/valuation/budget_investments_controller.rb
index c8d61215b..18f7e2599 100644
--- a/app/controllers/valuation/budget_investments_controller.rb
+++ b/app/controllers/valuation/budget_investments_controller.rb
@@ -70,7 +70,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
def valuation_params
params.require(:budget_investment).permit(:price, :price_first_year, :price_explanation,
:feasibility, :unfeasibility_explanation,
- :duration, :valuation_finished, :internal_comments)
+ :duration, :valuation_finished)
end
def restrict_access_to_assigned_items
diff --git a/app/views/valuation/budget_investments/_written_by_valuators.html.erb b/app/views/valuation/budget_investments/_written_by_valuators.html.erb
index 9dc5a8e8c..18beee4dc 100644
--- a/app/views/valuation/budget_investments/_written_by_valuators.html.erb
+++ b/app/views/valuation/budget_investments/_written_by_valuators.html.erb
@@ -47,7 +47,3 @@
<% end %>
-<% if @investment.internal_comments.present? %>
-
-
- <%= f.label :internal_comments, t("valuation.budget_investments.edit.internal_comments_html") %>
- <%= f.text_area :internal_comments, label: false, rows: 3 %>
-
-
-
<%= f.submit(class: "button expanded large", value: t("valuation.budget_investments.edit.save")) %>
diff --git a/config/locales/en/valuation.yml b/config/locales/en/valuation.yml
index d1c267305..fa53a432c 100644
--- a/config/locales/en/valuation.yml
+++ b/config/locales/en/valuation.yml
@@ -53,7 +53,6 @@ en:
undefined: Undefined
valuation_finished: Valuation finished
duration: Time scope
- internal_comments: Internal comments
responsibles: Responsibles
assigned_admin: Assigned admin
assigned_valuators: Assigned valuators
@@ -71,7 +70,6 @@ en:
valuation_finished_alert: "Are you sure you want to mark this report as completed? If you do it, it can no longer be modified."
not_feasible_alert: "An email will be sent immediately to the author of the project with the report of unfeasibility."
duration_html: Time scope
- internal_comments_html: Internal comments
save: Save changes
notice:
valuate: "Dossier updated"
diff --git a/config/locales/es/valuation.yml b/config/locales/es/valuation.yml
index 15c0c6d2c..9ddb2d009 100644
--- a/config/locales/es/valuation.yml
+++ b/config/locales/es/valuation.yml
@@ -53,7 +53,6 @@ es:
undefined: Sin definir
valuation_finished: Informe finalizado
duration: Plazo de ejecución
- internal_comments: Comentarios internos
responsibles: Responsables
assigned_admin: Administrador asignado
assigned_valuators: Evaluadores asignados
@@ -71,7 +70,6 @@ es:
valuation_finished_alert: "¿Estás seguro/a de querer marcar este informe como completado? Una vez hecho, no se puede deshacer la acción."
not_feasible_alert: "Un email será enviado inmediatamente al autor del proyecto con el informe de inviabilidad."
duration_html: Plazo de ejecución (opcional, dato no público)
- internal_comments_html: Comentarios y observaciones (para responsables internos, dato no público)
save: Guardar Cambios
notice:
valuate: "Dossier actualizado"
diff --git a/spec/features/valuation/budget_investments_spec.rb b/spec/features/valuation/budget_investments_spec.rb
index 33ab47b8e..032fe92a6 100644
--- a/spec/features/valuation/budget_investments_spec.rb
+++ b/spec/features/valuation/budget_investments_spec.rb
@@ -235,7 +235,6 @@ feature 'Valuation budget investments' do
within('#duration') { expect(page).to have_content('Undefined') }
within('#feasibility') { expect(page).to have_content('Undecided') }
expect(page).not_to have_content('Valuation finished')
- expect(page).not_to have_content('Internal comments')
end
scenario 'Edit dossier' do
@@ -249,7 +248,6 @@ feature 'Valuation budget investments' do
fill_in 'budget_investment_price_explanation', with: 'Very cheap idea'
choose 'budget_investment_feasibility_feasible'
fill_in 'budget_investment_duration', with: '19 months'
- fill_in 'budget_investment_internal_comments', with: 'Should be double checked by the urbanism area'
click_button 'Save changes'
expect(page).to have_content "Dossier updated"
@@ -263,8 +261,6 @@ feature 'Valuation budget investments' do
within('#duration') { expect(page).to have_content('19 months') }
within('#feasibility') { expect(page).to have_content('Feasible') }
expect(page).not_to have_content('Valuation finished')
- expect(page).to have_content('Internal comments')
- expect(page).to have_content('Should be double checked by the urbanism area')
end
scenario 'Feasibility can be marked as pending' do
@@ -290,7 +286,7 @@ feature 'Valuation budget investments' do
scenario 'Feasibility selection makes proper fields visible', :js do
feasible_fields = ['Price (€)', 'Cost during the first year (€)', 'Price explanation', 'Time scope']
unfeasible_fields = ['Feasibility explanation']
- any_feasibility_fields = ['Valuation finished', 'Internal comments']
+ any_feasibility_fields = ['Valuation finished']
undecided_fields = feasible_fields + unfeasible_fields + any_feasibility_fields
visit edit_valuation_budget_budget_investment_path(@budget, @investment)
From 09aa5a17cf9ddca705a4742e6245ba6cfad1fc10 Mon Sep 17 00:00:00 2001
From: Bertocq
Date: Mon, 29 Jan 2018 21:36:27 +0100
Subject: [PATCH 2/3] Add rake task to migrate investment's internal comments
to thread
---
lib/tasks/investments.rake | 12 ++++++++++++
1 file changed, 12 insertions(+)
create mode 100644 lib/tasks/investments.rake
diff --git a/lib/tasks/investments.rake b/lib/tasks/investments.rake
new file mode 100644
index 000000000..f9619b5ed
--- /dev/null
+++ b/lib/tasks/investments.rake
@@ -0,0 +1,12 @@
+namespace :investments do
+ namespace :internal_comments do
+ desc "Migrate internal_comments textarea to a first comment on internal thread"
+ task migrate_to_thread: :environment do
+ comments_author_id = Administrator.first.user.id
+ Budget::Investment.where.not(internal_comments: [nil, '']).find_each do |investment|
+ Comment.create(commentable: investment, user_id: comments_author_id,
+ body: investment.internal_comments, valuation: true)
+ end
+ end
+ end
+end
From 679cf3943ebd67c9f2221e7340ffb6bf71ad4450 Mon Sep 17 00:00:00 2001
From: Bertocq
Date: Mon, 29 Jan 2018 21:39:35 +0100
Subject: [PATCH 3/3] Update Deprecated section of Unreleased at Changelog file
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 09a2314d7..62b84114b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Deprecated
- Budget's `description_*` columns will be erased from database in next release. Please run rake task `budgets:phases:generate_missing` to migrate them. Details at Warning section of https://github.com/consul/consul/pull/2323
+- Budget::Investment's `internal_comments` attribute usage was removed, because of https://github.com/consul/consul/pull/2403, run rake task `investments:internal_comments:migrate_to_thread` to migrate existing values to the new internal comments thread. In next release database column will be removed.
### Removed
- Spending Proposals urls from sitemap, that model is getting entirely deprecated soon.