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
|
||||
|
||||
def budget_heading_params
|
||||
params.require(:budget_heading).permit(:name, :price, :geozone_id)
|
||||
params.require(:budget_heading).permit(:name, :price, :population)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" class="with-button">
|
||||
<th colspan="3" class="with-button">
|
||||
<%= 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" } %>
|
||||
</th>
|
||||
@@ -21,6 +21,7 @@
|
||||
<tr>
|
||||
<th><%= t("admin.budgets.form.table_heading") %></th>
|
||||
<th><%= t("admin.budgets.form.table_amount") %></th>
|
||||
<th><%= t("admin.budgets.form.table_population") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -45,6 +46,15 @@
|
||||
placeholder: t("admin.budgets.form.amount") %>
|
||||
</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" %>
|
||||
<% end %>
|
||||
@@ -60,6 +70,9 @@
|
||||
<td>
|
||||
<%= heading.price %>
|
||||
</td>
|
||||
<td>
|
||||
<%= heading.population %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<!-- /. headings list -->
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user