Add budget investments translation interface
* Adapt translatable spec helper method to work with budget investments * Remove old attributes from strong parameters * Add missing locales to admin.yml and budgets.yml * Change SpendingProposal.title_max_length and SpendingProposal.description_max_lenght to Budget::Investment methods * Add budget investment translatable attribute translations
This commit is contained in:
committed by
voodoorai2000
parent
5eb5f02cbe
commit
661ca5a568
@@ -3,6 +3,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
|
|||||||
include CommentableActions
|
include CommentableActions
|
||||||
include DownloadSettingsHelper
|
include DownloadSettingsHelper
|
||||||
include ChangeLogHelper
|
include ChangeLogHelper
|
||||||
|
include Translatable
|
||||||
|
|
||||||
feature_flag :budgets
|
feature_flag :budgets
|
||||||
|
|
||||||
@@ -87,10 +88,10 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def budget_investment_params
|
def budget_investment_params
|
||||||
params.require(:budget_investment)
|
attributes = [:external_url, :heading_id, :administrator_id, :tag_list,
|
||||||
.permit(:title, :description, :external_url, :heading_id, :administrator_id, :tag_list,
|
|
||||||
:valuation_tag_list, :incompatible, :visible_to_valuators, :selected,
|
:valuation_tag_list, :incompatible, :visible_to_valuators, :selected,
|
||||||
:milestone_tag_list, tracker_ids: [], valuator_ids: [], valuator_group_ids: [])
|
:milestone_tag_list, tracker_ids: [], valuator_ids: [], valuator_group_ids: []]
|
||||||
|
params.require(:budget_investment).permit(attributes, translation_params(Budget::Investment))
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_budget
|
def load_budget
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ module Budgets
|
|||||||
include FlagActions
|
include FlagActions
|
||||||
include RandomSeed
|
include RandomSeed
|
||||||
include ImageAttributes
|
include ImageAttributes
|
||||||
|
include Translatable
|
||||||
|
|
||||||
PER_PAGE = 10
|
PER_PAGE = 10
|
||||||
|
|
||||||
@@ -122,12 +123,12 @@ module Budgets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def investment_params
|
def investment_params
|
||||||
params.require(:budget_investment)
|
attributes = [:heading_id, :tag_list,
|
||||||
.permit(:title, :description, :heading_id, :tag_list,
|
|
||||||
:organization_name, :location, :terms_of_service, :skip_map,
|
:organization_name, :location, :terms_of_service, :skip_map,
|
||||||
image_attributes: image_attributes,
|
image_attributes: image_attributes,
|
||||||
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy],
|
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy],
|
||||||
map_location_attributes: [:latitude, :longitude, :zoom])
|
map_location_attributes: [:latitude, :longitude, :zoom]]
|
||||||
|
params.require(:budget_investment).permit(attributes, translation_params(Budget::Investment))
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_ballot
|
def load_ballot
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
class Management::Budgets::InvestmentsController < Management::BaseController
|
class Management::Budgets::InvestmentsController < Management::BaseController
|
||||||
|
include Translatable
|
||||||
before_action :load_budget
|
before_action :load_budget
|
||||||
|
|
||||||
load_resource :budget
|
load_resource :budget
|
||||||
@@ -53,8 +54,8 @@ class Management::Budgets::InvestmentsController < Management::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def investment_params
|
def investment_params
|
||||||
params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id,
|
attributes = [:external_url, :heading_id, :tag_list, :organization_name, :location, :skip_map]
|
||||||
:tag_list, :organization_name, :location, :skip_map)
|
params.require(:budget_investment).permit(attributes, translation_params(Budget::Investment))
|
||||||
end
|
end
|
||||||
|
|
||||||
def only_verified_users
|
def only_verified_users
|
||||||
|
|||||||
@@ -2,24 +2,30 @@
|
|||||||
<span class="icon-angle-left"></span> <%= t("shared.back") %>
|
<span class="icon-angle-left"></span> <%= t("shared.back") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= form_for @investment,
|
<%= render "admin/shared/globalize_locales", resource: @investment %>
|
||||||
|
|
||||||
|
<%= translatable_form_for @investment,
|
||||||
url: admin_budget_budget_investment_path(@budget, @investment) do |f| %>
|
url: admin_budget_budget_investment_path(@budget, @investment) do |f| %>
|
||||||
|
|
||||||
|
<%= render "shared/errors", resource: @investment %>
|
||||||
|
|
||||||
<% Budget::Investment.filter_params(params).to_h.each do |filter_name, filter_value| %>
|
<% Budget::Investment.filter_params(params).to_h.each do |filter_name, filter_value| %>
|
||||||
<%= hidden_field_tag filter_name, filter_value %>
|
<%= hidden_field_tag filter_name, filter_value %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="row expanded">
|
<div class="row expanded">
|
||||||
|
<%= f.translatable_fields do |translations_form| %>
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= f.text_field :title,
|
<%= translations_form.text_field :title,
|
||||||
maxlength: Budget::Investment.title_max_length %>
|
maxlength: Budget::Investment.title_max_length %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ckeditor small-12 column">
|
<div class="ckeditor small-12 column">
|
||||||
<%= f.cktext_area :description,
|
<%= translations_form.cktext_area :description,
|
||||||
maxlength: Budget::Investment.description_max_length,
|
maxlength: Budget::Investment.description_max_length,
|
||||||
ckeditor: { language: I18n.locale } %>
|
ckeditor: { language: I18n.locale } %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= f.label :tag_list, t("admin.budget_investments.edit.user_tags") %>
|
<%= f.label :tag_list, t("admin.budget_investments.edit.user_tags") %>
|
||||||
@@ -51,7 +57,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= f.label :valuation_tag_list, t("admin.budget_investments.edit.tags") %>
|
<%= f.label :valuation_tag_list, t("admin.budget_investments.edit.tags") %>
|
||||||
<div class="tags">
|
<div class="tags">
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<%= form_for(@investment, url: form_url, method: :post, html: { multipart: true }) do |f| %>
|
<%= render "admin/shared/globalize_locales", resource: @investment %>
|
||||||
|
|
||||||
|
<%= translatable_form_for(@investment, url: form_url, method: :post, html: { multipart: true }) do |f| %>
|
||||||
|
|
||||||
<%= render "shared/errors", resource: @investment %>
|
<%= render "shared/errors", resource: @investment %>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -6,22 +9,24 @@
|
|||||||
<%= f.select :heading_id, budget_heading_select_options(@budget), {include_blank: true, } %>
|
<%= f.select :heading_id, budget_heading_select_options(@budget), {include_blank: true, } %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%= f.translatable_fields do |translations_form| %>
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= f.text_field :title,
|
<%= translations_form.text_field :title,
|
||||||
maxlength: Budget::Investment.title_max_length,
|
maxlength: Budget::Investment.title_max_length,
|
||||||
data: { js_suggest_result: "js_suggest_result",
|
data: { js_suggest_result: "js_suggest_result",
|
||||||
js_suggest: "#js-suggest",
|
js_suggest: ".js-suggest",
|
||||||
js_url: suggest_budget_investments_path(@budget) }%>
|
js_url: suggest_budget_investments_path(@budget) }%>
|
||||||
</div>
|
</div>
|
||||||
<div id="js-suggest"></div>
|
<div class="js-suggest" data-locale="<%= translations_form.locale %>"></div>
|
||||||
|
|
||||||
<%= f.invisible_captcha :subtitle %>
|
|
||||||
|
|
||||||
<div class="ckeditor small-12 column">
|
<div class="ckeditor small-12 column">
|
||||||
<%= f.cktext_area :description,
|
<%= translations_form.cktext_area :description,
|
||||||
maxlength: Budget::Investment.description_max_length,
|
maxlength: Budget::Investment.description_max_length,
|
||||||
ckeditor: { language: I18n.locale } %>
|
ckeditor: { language: I18n.locale } %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= f.invisible_captcha :subtitle %>
|
||||||
|
|
||||||
<% if feature?(:allow_images) %>
|
<% if feature?(:allow_images) %>
|
||||||
<div class="images small-12 column">
|
<div class="images small-12 column">
|
||||||
|
|||||||
@@ -150,6 +150,9 @@ en:
|
|||||||
organization_name: "If you are proposing in the name of a collective/organization, or on behalf of more people, write its name"
|
organization_name: "If you are proposing in the name of a collective/organization, or on behalf of more people, write its name"
|
||||||
image: "Proposal descriptive image"
|
image: "Proposal descriptive image"
|
||||||
image_title: "Image title"
|
image_title: "Image title"
|
||||||
|
budget/investment/translation:
|
||||||
|
title: "Title"
|
||||||
|
description: "Description"
|
||||||
geozone:
|
geozone:
|
||||||
name: Name
|
name: Name
|
||||||
external_code: "External code (optional)"
|
external_code: "External code (optional)"
|
||||||
|
|||||||
@@ -152,6 +152,9 @@ es:
|
|||||||
organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre"
|
organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre"
|
||||||
image: "Imagen descriptiva del proyecto de gasto"
|
image: "Imagen descriptiva del proyecto de gasto"
|
||||||
image_title: "Título de la imagen"
|
image_title: "Título de la imagen"
|
||||||
|
budget/investment/translation:
|
||||||
|
title: "Título"
|
||||||
|
description: "Descripción"
|
||||||
geozone:
|
geozone:
|
||||||
name: Nombre
|
name: Nombre
|
||||||
external_code: "Código externo (opcional)"
|
external_code: "Código externo (opcional)"
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ describe "Admin budget investments" do
|
|||||||
:budget_investment,
|
:budget_investment,
|
||||||
"admin_budget_budget_investment_path"
|
"admin_budget_budget_investment_path"
|
||||||
|
|
||||||
|
it_behaves_like "translatable",
|
||||||
|
:budget_investment,
|
||||||
|
"edit_admin_budget_budget_investment_path",
|
||||||
|
%w[title],
|
||||||
|
{ "description" => :ckeditor }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@admin = create(:administrator)
|
@admin = create(:administrator)
|
||||||
login_as(@admin.user)
|
login_as(@admin.user)
|
||||||
|
|||||||
@@ -402,6 +402,8 @@ def update_button_text
|
|||||||
"Update milestone"
|
"Update milestone"
|
||||||
when "AdminNotification"
|
when "AdminNotification"
|
||||||
"Update notification"
|
"Update notification"
|
||||||
|
when "Budget::Investment"
|
||||||
|
"Update"
|
||||||
when "Poll"
|
when "Poll"
|
||||||
"Update poll"
|
"Update poll"
|
||||||
when "Budget"
|
when "Budget"
|
||||||
|
|||||||
Reference in New Issue
Block a user