From 3c9e08b06f1b3773236354bf6bc89e9cc4c0f528 Mon Sep 17 00:00:00 2001 From: kikito Date: Fri, 6 Jan 2017 18:43:55 +0100 Subject: [PATCH] Adds organization_name attribute to budget investments --- .../budgets/investments_controller.rb | 2 +- app/views/budgets/investments/_form.html.erb | 21 +++++++++---------- .../investments/_investment_show.html.erb | 8 ++++++- config/locales/activerecord.en.yml | 2 ++ config/locales/activerecord.es.yml | 2 ++ config/locales/budgets.en.yml | 1 + config/locales/budgets.es.yml | 1 + ...ization_name_field_to_budget_investment.rb | 5 +++++ db/schema.rb | 3 ++- 9 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 db/migrate/20170106130838_add_organization_name_field_to_budget_investment.rb diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 60cce8682..823953084 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, :location) + params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :terms_of_service, :location, :organization_name) end def load_ballot diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index f625a5271..3627b398d 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -3,30 +3,29 @@
- <%= f.label :heading_id, t("budget.investments.form.heading") %> - <%= f.select :heading_id, budget_heading_select_options(@budget), {include_blank: true, label: false} %> + <%= f.select :heading_id, budget_heading_select_options(@budget), {include_blank: true, } %>
- <%= f.label :title, t("budget.investments.form.title") %> - <%= f.text_field :title, maxlength: SpendingProposal.title_max_length, placeholder: t("budget.investments.form.title"), label: false %> + <%= f.text_field :title, maxlength: SpendingProposal.title_max_length %>
<%= f.invisible_captcha :subtitle %>
- <%= f.label :description, t("budget.investments.form.description") %> - <%= f.cktext_area :description, maxlength: SpendingProposal.description_max_length, ckeditor: { language: I18n.locale }, label: false %> + <%= f.cktext_area :description, maxlength: SpendingProposal.description_max_length, ckeditor: { language: I18n.locale } %>
- <%= f.label :external_url, t("budget.investments.form.external_url") %> - <%= f.text_field :external_url, placeholder: t("budget.investments.form.external_url"), label: false %> + <%= f.text_field :external_url %>
- <%= f.label :location, t("budget.investments.form.location") %> - <%= f.text_field :location, placeholder: t("budget.investments.form.location"), label: false %> + <%= f.text_field :location %> +
+ +
+ <%= f.text_field :organization_name %>
<% unless current_user.manager? %> @@ -45,7 +44,7 @@ <% end %>
- <%= f.submit(class: "button expanded", value: t("budget.investments.form.submit_buttons.#{action_name}")) %> + <%= f.submit(nil, class: "button expanded") %>
<% end %> diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index 9592d7cf2..1cc3281c2 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -24,11 +24,17 @@

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

+

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

<% end %> + <% if investment.organization_name.present? %> +

+ <%= t("budget.investments.show.organization_name_html", name: investment.organization_name) %> +

+ <% end %> + <%= safe_html_with_links investment.description.html_safe %> <% if investment.external_url.present? %> diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml index a9c4ba1bc..0c00b98ae 100644 --- a/config/locales/activerecord.en.yml +++ b/config/locales/activerecord.en.yml @@ -58,6 +58,8 @@ en: external_url: "Link to additional documentation" heading_id: "Heading" title: "Title" + location: "Location" + organization_name: "If you are proposing in the name of a collective/organization, write its name" comment: body: "Comment" user: "User" diff --git a/config/locales/activerecord.es.yml b/config/locales/activerecord.es.yml index 3299e86eb..c71a34178 100644 --- a/config/locales/activerecord.es.yml +++ b/config/locales/activerecord.es.yml @@ -58,6 +58,8 @@ es: external_url: "Enlace a documentación adicional" heading_id: "Partida presupuestaria" title: "Título" + location: "Ubicación" + organization_name: "Si estás proponiendo en nombre de una organización o colectivo, escribe su nombre" comment: body: "Comentario" user: "Usuario" diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml index cba5f96f0..844c572ae 100644 --- a/config/locales/budgets.en.yml +++ b/config/locales/budgets.en.yml @@ -104,6 +104,7 @@ en: unfeasibility_explanation: Unfeasibility explanation code_html: 'Investment project code: %{code}' location_html: 'Location: %{location}' + organization_name_html: 'Organization: %{name}' location: Location share: Share wrong_price_format: Only integer numbers diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml index 927d541c8..11b48b520 100644 --- a/config/locales/budgets.es.yml +++ b/config/locales/budgets.es.yml @@ -104,6 +104,7 @@ es: unfeasibility_explanation: Informe de inviabilidad code_html: 'Código propuesta de gasto: %{code}' location_html: 'Ubicación: %{location}' + organization_name_html: 'Organización: %{name}' share: Compartir wrong_price_format: Solo puede incluir caracteres numéricos investment: diff --git a/db/migrate/20170106130838_add_organization_name_field_to_budget_investment.rb b/db/migrate/20170106130838_add_organization_name_field_to_budget_investment.rb new file mode 100644 index 000000000..dfe9eca06 --- /dev/null +++ b/db/migrate/20170106130838_add_organization_name_field_to_budget_investment.rb @@ -0,0 +1,5 @@ +class AddOrganizationNameFieldToBudgetInvestment < ActiveRecord::Migration + def change + add_column :budget_investments, :organization_name, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 7ebc5f684..6a9498399 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: 20170103170147) do +ActiveRecord::Schema.define(version: 20170106130838) 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: 20170103170147) do t.integer "group_id" t.boolean "selected", default: false t.string "location" + t.string "organization_name" end add_index "budget_investments", ["administrator_id"], name: "index_budget_investments_on_administrator_id", using: :btree