Translate budget and budget phase main link url
This commit is contained in:
@@ -49,11 +49,11 @@
|
|||||||
<p class="help-text"> <%= t("admin.budget_phases.edit.main_call_to_action_description") %></p>
|
<p class="help-text"> <%= t("admin.budget_phases.edit.main_call_to_action_description") %></p>
|
||||||
<%= translations_form.text_field :main_link_text %>
|
<%= translations_form.text_field :main_link_text %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= f.text_field :main_link_url, placeholder: t("admin.shared.example_url") %>
|
<%= translations_form.text_field :main_link_url, placeholder: t("admin.shared.example_url") %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% if feature?(:allow_images) %>
|
<% if feature?(:allow_images) %>
|
||||||
<div class="images small-12 column">
|
<div class="images small-12 column">
|
||||||
|
|||||||
@@ -21,13 +21,12 @@
|
|||||||
<%= translations_form.text_field :main_link_text %>
|
<%= translations_form.text_field :main_link_text %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div class="row expanded">
|
<div class="row expanded">
|
||||||
<div class="small-12 medium-9 large-6 column end">
|
<div class="small-12 medium-9 large-6 column end">
|
||||||
<%= f.text_field :main_link_url, placeholder: t("admin.shared.example_url") %>
|
<%= translations_form.text_field :main_link_url, placeholder: t("admin.shared.example_url") %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="row expanded">
|
<div class="row expanded">
|
||||||
<div class="small-12 medium-4 column">
|
<div class="small-12 medium-4 column">
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ class Admin::BudgetsController < Admin::BaseController
|
|||||||
valid_attributes = [:phase,
|
valid_attributes = [:phase,
|
||||||
:currency_symbol,
|
:currency_symbol,
|
||||||
:voting_style,
|
:voting_style,
|
||||||
:main_link_url,
|
|
||||||
administrator_ids: [],
|
administrator_ids: [],
|
||||||
valuator_ids: [],
|
valuator_ids: [],
|
||||||
image_attributes: image_attributes
|
image_attributes: image_attributes
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Admin::BudgetsWizard::BudgetsController < Admin::BudgetsWizard::BaseContro
|
|||||||
end
|
end
|
||||||
|
|
||||||
def allowed_params
|
def allowed_params
|
||||||
valid_attributes = [:currency_symbol, :voting_style, :main_link_url, administrator_ids: [],
|
valid_attributes = [:currency_symbol, :voting_style, administrator_ids: [],
|
||||||
valuator_ids: [], image_attributes: image_attributes]
|
valuator_ids: [], image_attributes: image_attributes]
|
||||||
|
|
||||||
valid_attributes + [translation_params(Budget)]
|
valid_attributes + [translation_params(Budget)]
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ module Admin::BudgetPhasesActions
|
|||||||
end
|
end
|
||||||
|
|
||||||
def budget_phase_params
|
def budget_phase_params
|
||||||
valid_attributes = [:starts_at, :ends_at, :enabled, :main_link_url,
|
valid_attributes = [:starts_at, :ends_at, :enabled,
|
||||||
image_attributes: image_attributes]
|
image_attributes: image_attributes]
|
||||||
params.require(:budget_phase).permit(*valid_attributes, translation_params(Budget::Phase))
|
params.require(:budget_phase).permit(*valid_attributes, translation_params(Budget::Phase))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class Budget < ApplicationRecord
|
|||||||
include Reportable
|
include Reportable
|
||||||
include Imageable
|
include Imageable
|
||||||
|
|
||||||
translates :name, :main_link_text, touch: true
|
translates :name, :main_link_text, :main_link_url, touch: true
|
||||||
include Globalizable
|
include Globalizable
|
||||||
|
|
||||||
class Translation
|
class Translation
|
||||||
@@ -24,11 +24,11 @@ class Budget < ApplicationRecord
|
|||||||
VOTING_STYLES = %w[knapsack approval].freeze
|
VOTING_STYLES = %w[knapsack approval].freeze
|
||||||
|
|
||||||
validates_translation :name, presence: true
|
validates_translation :name, presence: true
|
||||||
|
validates_translation :main_link_url, presence: true, unless: -> { main_link_text.blank? }
|
||||||
validates :phase, inclusion: { in: Budget::Phase::PHASE_KINDS }
|
validates :phase, inclusion: { in: Budget::Phase::PHASE_KINDS }
|
||||||
validates :currency_symbol, presence: true
|
validates :currency_symbol, presence: true
|
||||||
validates :slug, presence: true, format: /\A[a-z0-9\-_]+\z/
|
validates :slug, presence: true, format: /\A[a-z0-9\-_]+\z/
|
||||||
validates :voting_style, inclusion: { in: VOTING_STYLES }
|
validates :voting_style, inclusion: { in: VOTING_STYLES }
|
||||||
validates :main_link_url, presence: true, if: -> { main_link_text.present? }
|
|
||||||
|
|
||||||
has_many :investments, dependent: :destroy
|
has_many :investments, dependent: :destroy
|
||||||
has_many :ballots, dependent: :destroy
|
has_many :ballots, dependent: :destroy
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Budget
|
|||||||
translates :summary, touch: true
|
translates :summary, touch: true
|
||||||
translates :description, touch: true
|
translates :description, touch: true
|
||||||
translates :main_link_text, touch: true
|
translates :main_link_text, touch: true
|
||||||
|
translates :main_link_url, touch: true
|
||||||
include Globalizable
|
include Globalizable
|
||||||
include Sanitizable
|
include Sanitizable
|
||||||
include Imageable
|
include Imageable
|
||||||
@@ -19,9 +20,9 @@ class Budget
|
|||||||
|
|
||||||
validates_translation :name, presence: true
|
validates_translation :name, presence: true
|
||||||
validates_translation :description, length: { maximum: DESCRIPTION_MAX_LENGTH }
|
validates_translation :description, length: { maximum: DESCRIPTION_MAX_LENGTH }
|
||||||
|
validates_translation :main_link_url, presence: true, unless: -> { main_link_text.blank? }
|
||||||
validates :budget, presence: true
|
validates :budget, presence: true
|
||||||
validates :kind, presence: true, uniqueness: { scope: :budget }, inclusion: { in: ->(*) { PHASE_KINDS }}
|
validates :kind, presence: true, uniqueness: { scope: :budget }, inclusion: { in: ->(*) { PHASE_KINDS }}
|
||||||
validates :main_link_url, presence: true, if: -> { main_link_text.present? }
|
|
||||||
validate :invalid_dates_range?
|
validate :invalid_dates_range?
|
||||||
validate :prev_phase_dates_valid?
|
validate :prev_phase_dates_valid?
|
||||||
validate :next_phase_dates_valid?
|
validate :next_phase_dates_valid?
|
||||||
|
|||||||
@@ -160,9 +160,9 @@ en:
|
|||||||
voting_style: "Final voting style"
|
voting_style: "Final voting style"
|
||||||
voting_style_knapsack: "Knapsack"
|
voting_style_knapsack: "Knapsack"
|
||||||
voting_style_approval: "Approval"
|
voting_style_approval: "Approval"
|
||||||
main_link_url: "The link takes you to (add a link)"
|
|
||||||
budget/translation:
|
budget/translation:
|
||||||
main_link_text: "Text on the link"
|
main_link_text: "Text on the link"
|
||||||
|
main_link_url: "The link takes you to (add a link)"
|
||||||
name: "Name"
|
name: "Name"
|
||||||
budget/investment:
|
budget/investment:
|
||||||
heading_id: "Heading"
|
heading_id: "Heading"
|
||||||
@@ -231,12 +231,12 @@ en:
|
|||||||
enabled: "Phase enabled"
|
enabled: "Phase enabled"
|
||||||
ends_at: "End date"
|
ends_at: "End date"
|
||||||
starts_at: "Start date"
|
starts_at: "Start date"
|
||||||
main_link_url: "The link takes you to (add a link)"
|
|
||||||
budget/phase/translation:
|
budget/phase/translation:
|
||||||
name: "Name"
|
name: "Name"
|
||||||
description: "Description"
|
description: "Description"
|
||||||
summary: "Summary"
|
summary: "Summary"
|
||||||
main_link_text: "Text on the link"
|
main_link_text: "Text on the link"
|
||||||
|
main_link_url: "The link takes you to (add a link)"
|
||||||
comment:
|
comment:
|
||||||
body: "Comment"
|
body: "Comment"
|
||||||
user: "User"
|
user: "User"
|
||||||
|
|||||||
@@ -160,9 +160,9 @@ es:
|
|||||||
voting_style: "Estilo de la votación final"
|
voting_style: "Estilo de la votación final"
|
||||||
voting_style_knapsack: Bolsa de dinero
|
voting_style_knapsack: Bolsa de dinero
|
||||||
voting_style_approval: Por aprobación
|
voting_style_approval: Por aprobación
|
||||||
main_link_url: "El enlace te lleva a (añade un enlace)"
|
|
||||||
budget/translation:
|
budget/translation:
|
||||||
main_link_text: "Texto del enlace"
|
main_link_text: "Texto del enlace"
|
||||||
|
main_link_url: "El enlace te lleva a (añade un enlace)"
|
||||||
name: "Nombre"
|
name: "Nombre"
|
||||||
budget/investment:
|
budget/investment:
|
||||||
heading_id: "Partida presupuestaria"
|
heading_id: "Partida presupuestaria"
|
||||||
@@ -231,12 +231,12 @@ es:
|
|||||||
enabled: "Fase habilitada"
|
enabled: "Fase habilitada"
|
||||||
ends_at: "Fecha de fin"
|
ends_at: "Fecha de fin"
|
||||||
starts_at: "Fecha de inicio"
|
starts_at: "Fecha de inicio"
|
||||||
main_link_url: "El enlace te lleva a (añade un enlace)"
|
|
||||||
budget/phase/translation:
|
budget/phase/translation:
|
||||||
name: "Nombre"
|
name: "Nombre"
|
||||||
description: "Descripción"
|
description: "Descripción"
|
||||||
summary: "Resumen"
|
summary: "Resumen"
|
||||||
main_link_text: "Texto del enlace"
|
main_link_text: "Texto del enlace"
|
||||||
|
main_link_url: "El enlace te lleva a (añade un enlace)"
|
||||||
comment:
|
comment:
|
||||||
body: "Comentario"
|
body: "Comentario"
|
||||||
user: "Usuario"
|
user: "Usuario"
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class TranslateBudgetMainLinkUrl < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :budget_translations, :main_link_url, :string
|
||||||
|
remove_column :budgets, :main_link_url, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class TranslateBudgetPhaseMainLinkUrl < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :budget_phase_translations, :main_link_url, :string
|
||||||
|
remove_column :budget_phases, :main_link_url, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -10,7 +10,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: 2021_08_25_152739) do
|
ActiveRecord::Schema.define(version: 2021_11_03_112944) 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 "pg_trgm"
|
enable_extension "pg_trgm"
|
||||||
@@ -316,6 +316,7 @@ ActiveRecord::Schema.define(version: 2021_08_25_152739) do
|
|||||||
t.text "summary"
|
t.text "summary"
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.string "main_link_text"
|
t.string "main_link_text"
|
||||||
|
t.string "main_link_url"
|
||||||
t.index ["budget_phase_id"], name: "index_budget_phase_translations_on_budget_phase_id"
|
t.index ["budget_phase_id"], name: "index_budget_phase_translations_on_budget_phase_id"
|
||||||
t.index ["locale"], name: "index_budget_phase_translations_on_locale"
|
t.index ["locale"], name: "index_budget_phase_translations_on_locale"
|
||||||
end
|
end
|
||||||
@@ -327,7 +328,6 @@ ActiveRecord::Schema.define(version: 2021_08_25_152739) do
|
|||||||
t.datetime "starts_at"
|
t.datetime "starts_at"
|
||||||
t.datetime "ends_at"
|
t.datetime "ends_at"
|
||||||
t.boolean "enabled", default: true
|
t.boolean "enabled", default: true
|
||||||
t.string "main_link_url"
|
|
||||||
t.index ["ends_at"], name: "index_budget_phases_on_ends_at"
|
t.index ["ends_at"], name: "index_budget_phases_on_ends_at"
|
||||||
t.index ["kind"], name: "index_budget_phases_on_kind"
|
t.index ["kind"], name: "index_budget_phases_on_kind"
|
||||||
t.index ["next_phase_id"], name: "index_budget_phases_on_next_phase_id"
|
t.index ["next_phase_id"], name: "index_budget_phases_on_next_phase_id"
|
||||||
@@ -349,6 +349,7 @@ ActiveRecord::Schema.define(version: 2021_08_25_152739) do
|
|||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.string "main_link_text"
|
t.string "main_link_text"
|
||||||
|
t.string "main_link_url"
|
||||||
t.index ["budget_id"], name: "index_budget_translations_on_budget_id"
|
t.index ["budget_id"], name: "index_budget_translations_on_budget_id"
|
||||||
t.index ["locale"], name: "index_budget_translations_on_locale"
|
t.index ["locale"], name: "index_budget_translations_on_locale"
|
||||||
end
|
end
|
||||||
@@ -393,7 +394,6 @@ ActiveRecord::Schema.define(version: 2021_08_25_152739) do
|
|||||||
t.text "description_informing"
|
t.text "description_informing"
|
||||||
t.string "voting_style", default: "knapsack"
|
t.string "voting_style", default: "knapsack"
|
||||||
t.boolean "published"
|
t.boolean "published"
|
||||||
t.string "main_link_url"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "campaigns", id: :serial, force: :cascade do |t|
|
create_table "campaigns", id: :serial, force: :cascade do |t|
|
||||||
|
|||||||
Reference in New Issue
Block a user