diff --git a/app/controllers/admin/budget_headings_controller.rb b/app/controllers/admin/budget_headings_controller.rb index 56903b744..eea93716f 100644 --- a/app/controllers/admin/budget_headings_controller.rb +++ b/app/controllers/admin/budget_headings_controller.rb @@ -12,7 +12,7 @@ class Admin::BudgetHeadingsController < Admin::BaseController private def budget_heading_params - params.require(:budget_heading).permit(:name, :price, :geozone_id) + params.require(:budget_heading).permit(:name, :price, :population) end -end \ No newline at end of file +end diff --git a/app/views/admin/budgets/_group.html.erb b/app/views/admin/budgets/_group.html.erb index 6193fe287..8537fa477 100644 --- a/app/views/admin/budgets/_group.html.erb +++ b/app/views/admin/budgets/_group.html.erb @@ -1,7 +1,7 @@
| + | <%= group.name %> <%= link_to t("admin.budgets.form.add_heading"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#group-#{group.id}-new-heading-form" } %> | @@ -21,6 +21,7 @@|||
|---|---|---|---|---|
| <%= t("admin.budgets.form.table_heading") %> | <%= t("admin.budgets.form.table_amount") %> | +<%= t("admin.budgets.form.table_population") %> | <%= heading.price %> | ++ <%= heading.population %> + | <% end %> diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 156decd7d..dd8ec1f85 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -97,10 +97,12 @@ en: heading: Heading name add_heading: Add heading amount: Amount + population: Population save_heading: Save heading no_heading: This group has no assigned heading. table_heading: Heading table_amount: Amount + table_population: Population winners: calculate: Calculate Winner Investments calculated: Winners being calculated, it may take a minute. diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index ba66a4052..21335d418 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -97,10 +97,12 @@ es: heading: Nombre de la partida add_heading: Añadir partida amount: Cantidad + population: Población save_heading: Guardar partida no_heading: Este grupo no tiene ninguna partida asignada. table_heading: Partida table_amount: Cantidad + table_population: Población winners: calculate: Calcular propuestas ganadoras calculated: Calculando ganadoras, puede tardar un minuto. diff --git a/config/locales/admin.fr.yml b/config/locales/admin.fr.yml index 549ddd813..5830488bb 100644 --- a/config/locales/admin.fr.yml +++ b/config/locales/admin.fr.yml @@ -97,10 +97,12 @@ fr: heading: Nom de la rubrique add_heading: Ajouter une rubrique amount: Montant + population: Population save_heading: Sauvegarder la rubrique no_heading: Ce groupe n'a pas de rubrique assignée. table_heading: Rubrique table_amount: Montant + table_population: Population winners: calculate: Calculate Winner Investments calculated: Winners being calculated, it may take a minute. diff --git a/config/locales/admin.nl.yml b/config/locales/admin.nl.yml index e401952c9..a421169f0 100755 --- a/config/locales/admin.nl.yml +++ b/config/locales/admin.nl.yml @@ -98,10 +98,12 @@ nl: heading: Heading name add_heading: Add heading amount: Amount + population: Population save_heading: Save heading no_heading: This group has no assigned heading. table_heading: Heading table_amount: Amount + table_population: Population winners: calculate: Calculate Winner Investments calculated: Winners being calculated, it may take a minute. diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 99605b392..42018d41d 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -390,7 +390,8 @@ Budget::PHASES.each_with_index do |phase, i| geozones = Geozone.reorder("RANDOM()").limit([2, 5, 6, 7].sample) geozones.each do |geozone| group.headings << group.headings.create!(name: geozone.name, - price: rand(1..100) * 100000) + price: rand(1..100) * 100000, + population: rand(1..50) * 10000) end end end diff --git a/db/migrate/20170621180611_add_population_to_budget_headings.rb b/db/migrate/20170621180611_add_population_to_budget_headings.rb new file mode 100644 index 000000000..fe723bc98 --- /dev/null +++ b/db/migrate/20170621180611_add_population_to_budget_headings.rb @@ -0,0 +1,5 @@ +class AddPopulationToBudgetHeadings < ActiveRecord::Migration + def change + add_column :budget_headings, :population, :integer, default: nil + end +end diff --git a/db/schema.rb b/db/schema.rb index 4cfa7229f..bb73ba406 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170620132731) do +ActiveRecord::Schema.define(version: 20170621180611) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -110,6 +110,7 @@ ActiveRecord::Schema.define(version: 20170620132731) do t.integer "group_id" t.string "name", limit: 50 t.integer "price", limit: 8 + t.integer "population" end add_index "budget_headings", ["group_id"], name: "index_budget_headings_on_group_id", using: :btree diff --git a/spec/factories.rb b/spec/factories.rb index a93d911ed..7397669bd 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -254,6 +254,7 @@ FactoryGirl.define do association :group, factory: :budget_group sequence(:name) { |n| "Heading #{n}" } price 1000000 + population 1234 end factory :budget_investment, class: 'Budget::Investment' do diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 4f78f3edf..d4ed2d2ac 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -183,6 +183,7 @@ feature 'Admin budgets' do fill_in 'budget_heading_name', with: 'District 9 reconstruction' fill_in 'budget_heading_price', with: '6785' + fill_in 'budget_heading_population', with: '100500' click_button 'Save heading' end @@ -194,6 +195,7 @@ feature 'Admin budgets' do expect(page).to have_content 'District 9 reconstruction' expect(page).to have_content '6785' + expect(page).to have_content '100500' end end