Merge pull request #1679 from consul/feature/add_population_to_budget_heading
Add Population field to Budget Headings
This commit is contained in:
@@ -12,7 +12,7 @@ class Admin::BudgetHeadingsController < Admin::BaseController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def budget_heading_params
|
def budget_heading_params
|
||||||
params.require(:budget_heading).permit(:name, :price, :geozone_id)
|
params.require(:budget_heading).permit(:name, :price, :population)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2" class="with-button">
|
<th colspan="3" class="with-button">
|
||||||
<%= group.name %>
|
<%= 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" } %>
|
<%= link_to t("admin.budgets.form.add_heading"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#group-#{group.id}-new-heading-form" } %>
|
||||||
</th>
|
</th>
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th><%= t("admin.budgets.form.table_heading") %></th>
|
<th><%= t("admin.budgets.form.table_heading") %></th>
|
||||||
<th><%= t("admin.budgets.form.table_amount") %></th>
|
<th><%= t("admin.budgets.form.table_amount") %></th>
|
||||||
|
<th><%= t("admin.budgets.form.table_population") %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -45,6 +46,15 @@
|
|||||||
placeholder: t("admin.budgets.form.amount") %>
|
placeholder: t("admin.budgets.form.amount") %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 medium-6 column">
|
||||||
|
<label><%= t("admin.budgets.form.population") %></label>
|
||||||
|
<%= f.text_field :population,
|
||||||
|
label: false,
|
||||||
|
maxlength: 8,
|
||||||
|
placeholder: t("admin.budgets.form.population") %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<%= f.submit t("admin.budgets.form.save_heading"), class: "button success" %>
|
<%= f.submit t("admin.budgets.form.save_heading"), class: "button success" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -60,6 +70,9 @@
|
|||||||
<td>
|
<td>
|
||||||
<%= heading.price %>
|
<%= heading.price %>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= heading.population %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!-- /. headings list -->
|
<!-- /. headings list -->
|
||||||
|
|||||||
@@ -97,10 +97,12 @@ en:
|
|||||||
heading: Heading name
|
heading: Heading name
|
||||||
add_heading: Add heading
|
add_heading: Add heading
|
||||||
amount: Amount
|
amount: Amount
|
||||||
|
population: Population
|
||||||
save_heading: Save heading
|
save_heading: Save heading
|
||||||
no_heading: This group has no assigned heading.
|
no_heading: This group has no assigned heading.
|
||||||
table_heading: Heading
|
table_heading: Heading
|
||||||
table_amount: Amount
|
table_amount: Amount
|
||||||
|
table_population: Population
|
||||||
winners:
|
winners:
|
||||||
calculate: Calculate Winner Investments
|
calculate: Calculate Winner Investments
|
||||||
calculated: Winners being calculated, it may take a minute.
|
calculated: Winners being calculated, it may take a minute.
|
||||||
|
|||||||
@@ -97,10 +97,12 @@ es:
|
|||||||
heading: Nombre de la partida
|
heading: Nombre de la partida
|
||||||
add_heading: Añadir partida
|
add_heading: Añadir partida
|
||||||
amount: Cantidad
|
amount: Cantidad
|
||||||
|
population: Población
|
||||||
save_heading: Guardar partida
|
save_heading: Guardar partida
|
||||||
no_heading: Este grupo no tiene ninguna partida asignada.
|
no_heading: Este grupo no tiene ninguna partida asignada.
|
||||||
table_heading: Partida
|
table_heading: Partida
|
||||||
table_amount: Cantidad
|
table_amount: Cantidad
|
||||||
|
table_population: Población
|
||||||
winners:
|
winners:
|
||||||
calculate: Calcular propuestas ganadoras
|
calculate: Calcular propuestas ganadoras
|
||||||
calculated: Calculando ganadoras, puede tardar un minuto.
|
calculated: Calculando ganadoras, puede tardar un minuto.
|
||||||
|
|||||||
@@ -97,10 +97,12 @@ fr:
|
|||||||
heading: Nom de la rubrique
|
heading: Nom de la rubrique
|
||||||
add_heading: Ajouter une rubrique
|
add_heading: Ajouter une rubrique
|
||||||
amount: Montant
|
amount: Montant
|
||||||
|
population: Population
|
||||||
save_heading: Sauvegarder la rubrique
|
save_heading: Sauvegarder la rubrique
|
||||||
no_heading: Ce groupe n'a pas de rubrique assignée.
|
no_heading: Ce groupe n'a pas de rubrique assignée.
|
||||||
table_heading: Rubrique
|
table_heading: Rubrique
|
||||||
table_amount: Montant
|
table_amount: Montant
|
||||||
|
table_population: Population
|
||||||
winners:
|
winners:
|
||||||
calculate: Calculate Winner Investments
|
calculate: Calculate Winner Investments
|
||||||
calculated: Winners being calculated, it may take a minute.
|
calculated: Winners being calculated, it may take a minute.
|
||||||
|
|||||||
@@ -98,10 +98,12 @@ nl:
|
|||||||
heading: Heading name
|
heading: Heading name
|
||||||
add_heading: Add heading
|
add_heading: Add heading
|
||||||
amount: Amount
|
amount: Amount
|
||||||
|
population: Population
|
||||||
save_heading: Save heading
|
save_heading: Save heading
|
||||||
no_heading: This group has no assigned heading.
|
no_heading: This group has no assigned heading.
|
||||||
table_heading: Heading
|
table_heading: Heading
|
||||||
table_amount: Amount
|
table_amount: Amount
|
||||||
|
table_population: Population
|
||||||
winners:
|
winners:
|
||||||
calculate: Calculate Winner Investments
|
calculate: Calculate Winner Investments
|
||||||
calculated: Winners being calculated, it may take a minute.
|
calculated: Winners being calculated, it may take a minute.
|
||||||
|
|||||||
@@ -390,7 +390,8 @@ Budget::PHASES.each_with_index do |phase, i|
|
|||||||
geozones = Geozone.reorder("RANDOM()").limit([2, 5, 6, 7].sample)
|
geozones = Geozone.reorder("RANDOM()").limit([2, 5, 6, 7].sample)
|
||||||
geozones.each do |geozone|
|
geozones.each do |geozone|
|
||||||
group.headings << group.headings.create!(name: geozone.name,
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddPopulationToBudgetHeadings < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :budget_headings, :population, :integer, default: nil
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -110,6 +110,7 @@ ActiveRecord::Schema.define(version: 20170620132731) do
|
|||||||
t.integer "group_id"
|
t.integer "group_id"
|
||||||
t.string "name", limit: 50
|
t.string "name", limit: 50
|
||||||
t.integer "price", limit: 8
|
t.integer "price", limit: 8
|
||||||
|
t.integer "population"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "budget_headings", ["group_id"], name: "index_budget_headings_on_group_id", using: :btree
|
add_index "budget_headings", ["group_id"], name: "index_budget_headings_on_group_id", using: :btree
|
||||||
|
|||||||
@@ -254,6 +254,7 @@ FactoryGirl.define do
|
|||||||
association :group, factory: :budget_group
|
association :group, factory: :budget_group
|
||||||
sequence(:name) { |n| "Heading #{n}" }
|
sequence(:name) { |n| "Heading #{n}" }
|
||||||
price 1000000
|
price 1000000
|
||||||
|
population 1234
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :budget_investment, class: 'Budget::Investment' do
|
factory :budget_investment, class: 'Budget::Investment' do
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ feature 'Admin budgets' do
|
|||||||
|
|
||||||
fill_in 'budget_heading_name', with: 'District 9 reconstruction'
|
fill_in 'budget_heading_name', with: 'District 9 reconstruction'
|
||||||
fill_in 'budget_heading_price', with: '6785'
|
fill_in 'budget_heading_price', with: '6785'
|
||||||
|
fill_in 'budget_heading_population', with: '100500'
|
||||||
click_button 'Save heading'
|
click_button 'Save heading'
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -194,6 +195,7 @@ feature 'Admin budgets' do
|
|||||||
|
|
||||||
expect(page).to have_content 'District 9 reconstruction'
|
expect(page).to have_content 'District 9 reconstruction'
|
||||||
expect(page).to have_content '6785'
|
expect(page).to have_content '6785'
|
||||||
|
expect(page).to have_content '100500'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user