Remove summary in phases form
Since it does not appear in the phases anymore. Also, the rake unifies the fields of the budget summary with the budget description.
This commit is contained in:
@@ -3,7 +3,6 @@ class Budget
|
|||||||
PHASE_KINDS = %w[informing accepting reviewing selecting valuating publishing_prices balloting
|
PHASE_KINDS = %w[informing accepting reviewing selecting valuating publishing_prices balloting
|
||||||
reviewing_ballots finished].freeze
|
reviewing_ballots finished].freeze
|
||||||
PUBLISHED_PRICES_PHASES = %w[publishing_prices balloting reviewing_ballots finished].freeze
|
PUBLISHED_PRICES_PHASES = %w[publishing_prices balloting reviewing_ballots finished].freeze
|
||||||
SUMMARY_MAX_LENGTH = 1000
|
|
||||||
DESCRIPTION_MAX_LENGTH = 2000
|
DESCRIPTION_MAX_LENGTH = 2000
|
||||||
|
|
||||||
translates :summary, touch: true
|
translates :summary, touch: true
|
||||||
@@ -15,7 +14,6 @@ class Budget
|
|||||||
belongs_to :next_phase, class_name: self.name, inverse_of: :prev_phase
|
belongs_to :next_phase, class_name: self.name, inverse_of: :prev_phase
|
||||||
has_one :prev_phase, class_name: self.name, foreign_key: :next_phase_id, inverse_of: :next_phase
|
has_one :prev_phase, class_name: self.name, foreign_key: :next_phase_id, inverse_of: :next_phase
|
||||||
|
|
||||||
validates_translation :summary, length: { maximum: SUMMARY_MAX_LENGTH }
|
|
||||||
validates_translation :description, length: { maximum: DESCRIPTION_MAX_LENGTH }
|
validates_translation :description, length: { maximum: DESCRIPTION_MAX_LENGTH }
|
||||||
validates :budget, presence: true
|
validates :budget, presence: true
|
||||||
validates :kind, presence: true, uniqueness: { scope: :budget }, inclusion: { in: ->(*) { PHASE_KINDS }}
|
validates :kind, presence: true, uniqueness: { scope: :budget }, inclusion: { in: ->(*) { PHASE_KINDS }}
|
||||||
|
|||||||
@@ -21,13 +21,6 @@
|
|||||||
class: "html-area",
|
class: "html-area",
|
||||||
hint: t("admin.budget_phases.edit.description_help_text") %>
|
hint: t("admin.budget_phases.edit.description_help_text") %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 column">
|
|
||||||
<%= translations_form.text_area :summary,
|
|
||||||
maxlength: Budget::Phase::SUMMARY_MAX_LENGTH,
|
|
||||||
class: "html-area",
|
|
||||||
hint: t("admin.budget_phases.edit.summary_help_text") %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -173,7 +173,6 @@ en:
|
|||||||
help: "Headings are meant to divide the money of the participatory budget. Here you can add headings for this group and assign the amount of money that will be used for each heading."
|
help: "Headings are meant to divide the money of the participatory budget. Here you can add headings for this group and assign the amount of money that will be used for each heading."
|
||||||
budget_phases:
|
budget_phases:
|
||||||
edit:
|
edit:
|
||||||
summary_help_text: This text will inform the user about the phase. To show it even if the phase is not active, select the checkbox below
|
|
||||||
description_help_text: This text will appear in the header when the phase is active
|
description_help_text: This text will appear in the header when the phase is active
|
||||||
enabled_help_text: This phase will be public in the budget's phases timeline, as well as active for any other purpose
|
enabled_help_text: This phase will be public in the budget's phases timeline, as well as active for any other purpose
|
||||||
save_changes: Save changes
|
save_changes: Save changes
|
||||||
|
|||||||
@@ -173,7 +173,6 @@ es:
|
|||||||
help: "Las partidas sirven para dividir el dinero del presupuesto participativo. Aquí puedes ir añadiendo partidas para cada grupo y establecer la cantidad de dinero que se gastará en cada partida."
|
help: "Las partidas sirven para dividir el dinero del presupuesto participativo. Aquí puedes ir añadiendo partidas para cada grupo y establecer la cantidad de dinero que se gastará en cada partida."
|
||||||
budget_phases:
|
budget_phases:
|
||||||
edit:
|
edit:
|
||||||
summary_help_text: Este texto informará al usuario sobre la fase. Para mostrarlo aunque la fase no esté activa, marca la opción de más abajo.
|
|
||||||
description_help_text: Este texto aparecerá en la cabecera cuando la fase esté activa
|
description_help_text: Este texto aparecerá en la cabecera cuando la fase esté activa
|
||||||
enabled_help_text: Esta fase será pública en el calendario de fases del presupuesto y estará activa para otros propósitos
|
enabled_help_text: Esta fase será pública en el calendario de fases del presupuesto y estará activa para otros propósitos
|
||||||
save_changes: Guardar cambios
|
save_changes: Guardar cambios
|
||||||
|
|||||||
@@ -29,4 +29,17 @@ namespace :budgets do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "Copies the Budget::Phase summary into description"
|
||||||
|
task phases_summary_to_description: :environment do
|
||||||
|
ApplicationLogger.new.info "Adding budget phases summary to descriptions"
|
||||||
|
|
||||||
|
Budget::Phase::Translation.find_each do |translation|
|
||||||
|
if translation.summary.present?
|
||||||
|
translation.description << "<br>"
|
||||||
|
translation.description << translation.summary
|
||||||
|
translation.update!(summary: nil) if translation.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace :consul do
|
|||||||
task "execute_release_1.3.0_tasks": [
|
task "execute_release_1.3.0_tasks": [
|
||||||
"db:load_sdg",
|
"db:load_sdg",
|
||||||
"db:calculate_tsv",
|
"db:calculate_tsv",
|
||||||
"budgets:set_published"
|
"budgets:set_published",
|
||||||
|
"budgets:phases_summary_to_description"
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe Budget do
|
describe "budget tasks" do
|
||||||
|
describe "set_published" do
|
||||||
let(:run_rake_task) do
|
let(:run_rake_task) do
|
||||||
Rake::Task["budgets:set_published"].reenable
|
Rake::Task["budgets:set_published"].reenable
|
||||||
Rake.application.invoke_task("budgets:set_published")
|
Rake.application.invoke_task("budgets:set_published")
|
||||||
@@ -68,3 +69,31 @@ describe Budget do
|
|||||||
expect(budget.published).to be false
|
expect(budget.published).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "phases_summary_to_description" do
|
||||||
|
let(:run_rake_task) do
|
||||||
|
Rake::Task["budgets:phases_summary_to_description"].reenable
|
||||||
|
Rake.application.invoke_task("budgets:phases_summary_to_description")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "appends the content of summary to the content of description" do
|
||||||
|
budget = create(:budget)
|
||||||
|
budget_phase = budget.phases.informing
|
||||||
|
budget_phase.update!(
|
||||||
|
description_en: "English description",
|
||||||
|
description_es: "Spanish description",
|
||||||
|
description_fr: "French description",
|
||||||
|
summary_en: "English summary",
|
||||||
|
summary_fr: "French summary"
|
||||||
|
)
|
||||||
|
|
||||||
|
run_rake_task
|
||||||
|
|
||||||
|
budget_phase.reload
|
||||||
|
expect(budget_phase.description_en).to eq "English description<br>English summary"
|
||||||
|
expect(budget_phase.description_es).to eq "Spanish description"
|
||||||
|
expect(budget_phase.description_fr).to eq "French description<br>French summary"
|
||||||
|
expect(budget_phase.summary).to be nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ describe "Admin budget phases" do
|
|||||||
|
|
||||||
fill_in "start_date", with: Date.current + 1.day
|
fill_in "start_date", with: Date.current + 1.day
|
||||||
fill_in "end_date", with: Date.current + 12.days
|
fill_in "end_date", with: Date.current + 12.days
|
||||||
fill_in_ckeditor "Summary", with: "New summary of the phase."
|
|
||||||
fill_in_ckeditor "Description", with: "New description of the phase."
|
fill_in_ckeditor "Description", with: "New description of the phase."
|
||||||
uncheck "budget_phase_enabled"
|
uncheck "budget_phase_enabled"
|
||||||
click_button "Save changes"
|
click_button "Save changes"
|
||||||
@@ -19,7 +18,6 @@ describe "Admin budget phases" do
|
|||||||
|
|
||||||
expect(budget.current_phase.starts_at.to_date).to eq((Date.current + 1.day).to_date)
|
expect(budget.current_phase.starts_at.to_date).to eq((Date.current + 1.day).to_date)
|
||||||
expect(budget.current_phase.ends_at.to_date).to eq((Date.current + 12.days).to_date)
|
expect(budget.current_phase.ends_at.to_date).to eq((Date.current + 12.days).to_date)
|
||||||
expect(budget.current_phase.summary).to include("New summary of the phase.")
|
|
||||||
expect(budget.current_phase.description).to include("New description of the phase.")
|
expect(budget.current_phase.description).to include("New description of the phase.")
|
||||||
expect(budget.current_phase.enabled).to be(false)
|
expect(budget.current_phase.enabled).to be(false)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user