From 110a4091f8cfce5e98ddcc5279b056fe8420705f Mon Sep 17 00:00:00 2001 From: kikito Date: Thu, 29 Dec 2016 17:30:21 +0100 Subject: [PATCH] Adds budget investment location --- app/controllers/budgets/investments_controller.rb | 2 +- app/views/budgets/investments/_form.html.erb | 5 +++++ app/views/budgets/investments/_investment_show.html.erb | 9 +++++++-- config/locales/budgets.en.yml | 7 +++++-- config/locales/budgets.es.yml | 4 +++- .../20161229153505_add_location_to_budget_investments.rb | 5 +++++ db/schema.rb | 5 +++-- 7 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20161229153505_add_location_to_budget_investments.rb diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 490b4047d..0084e71db 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -80,7 +80,7 @@ module Budgets end def investment_params - params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :terms_of_service) + params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :terms_of_service, :location) end def load_ballot diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index 93461a873..8e7643285 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -24,6 +24,11 @@ <%= f.text_field :external_url, placeholder: t("budget.investments.form.external_url"), label: false %> +
+ <%= f.label :location, t("budget.investments.form.location") %> + <%= f.text_field :location, placeholder: t("budget.investments.form.location"), label: false %> +
+ <% unless current_user.manager? %>
diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index b3cc81ba6..28659533d 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -26,10 +26,15 @@

- <%= t("budget.investments.show.code") %> - <%= investment.id %> + <%= t("budget.investments.show.code_html", code: investment.id) %>

+ <% if investment.location.present? %> +

+ <%= t("budget.investments.show.location_html", location: investment.location) %> +

+ <% end %> + <%= safe_html_with_links investment.description.html_safe %> <% if investment.external_url.present? %> diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml index f88cb6dea..31744d14f 100644 --- a/config/locales/budgets.en.yml +++ b/config/locales/budgets.en.yml @@ -36,7 +36,7 @@ en: none: Whole City all: All scopes index: - name: Budget's name + name: Budget name phase: Phase title: Participatory budgets investments: @@ -46,6 +46,7 @@ en: description: Description external_url: Link to additional documentation heading: Choose if a proposed citywide or district + location: "Location" submit_buttons: create: Create new: Create @@ -96,7 +97,9 @@ en: author_deleted: User deleted price_explanation: Price explanation unfeasibility_explanation: Unfeasibility explanation - code: 'Investment project code:' + code_html: 'Investment project code: %{code}' + location_html: 'Location: %{location}' + location: Location share: Share wrong_price_format: Only integer numbers investment: diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml index bc23711a9..97e2be653 100644 --- a/config/locales/budgets.es.yml +++ b/config/locales/budgets.es.yml @@ -46,6 +46,7 @@ es: description: Descripción detallada external_url: Enlace a documentación adicional heading: "Elige si es una propuesta para toda la ciudad o para un distrito" + location: "Localización de la propuesta" submit_buttons: create: Crear new: Crear @@ -96,7 +97,8 @@ es: author_deleted: Usuario eliminado price_explanation: Informe de coste unfeasibility_explanation: Informe de inviabilidad - code: 'Código propuesta de gasto:' + code_html: 'Código propuesta de gasto: %{code}' + location_html: 'Localización: %{location}' share: Compartir wrong_price_format: Solo puede incluir caracteres numéricos investment: diff --git a/db/migrate/20161229153505_add_location_to_budget_investments.rb b/db/migrate/20161229153505_add_location_to_budget_investments.rb new file mode 100644 index 000000000..a58ee4fdd --- /dev/null +++ b/db/migrate/20161229153505_add_location_to_budget_investments.rb @@ -0,0 +1,5 @@ +class AddLocationToBudgetInvestments < ActiveRecord::Migration + def change + add_column :budget_investments, :location, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index bff0fef16..2d68c3d11 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: 20161221172447) do +ActiveRecord::Schema.define(version: 20161229153505) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -142,6 +142,7 @@ ActiveRecord::Schema.define(version: 20161221172447) do t.integer "budget_id" t.integer "group_id" t.boolean "selected", default: false + t.string "location" end add_index "budget_investments", ["administrator_id"], name: "index_budget_investments_on_administrator_id", using: :btree @@ -572,7 +573,7 @@ ActiveRecord::Schema.define(version: 20161221172447) do t.boolean "email_digest", default: true t.boolean "email_on_direct_message", default: true t.boolean "official_position_badge", default: false - t.datetime "password_changed_at", default: '2016-12-21 17:55:08', null: false + t.datetime "password_changed_at", default: '2016-11-02 13:51:14', null: false t.boolean "created_from_signature", default: false end