<%= link_to decidim.root_path, class: "button__site", target: "_blank", data: { "external-link": false } do %>
diff --git a/decidim-admin/spec/commands/decidim/admin/update_organization_spec.rb b/decidim-admin/spec/commands/decidim/admin/update_organization_spec.rb
index 7887d5059c012..710fbb1b74301 100644
--- a/decidim-admin/spec/commands/decidim/admin/update_organization_spec.rb
+++ b/decidim-admin/spec/commands/decidim/admin/update_organization_spec.rb
@@ -10,7 +10,7 @@ module Decidim::Admin
let(:params) do
{
organization: {
- name: "My super organization",
+ name: { en: "My super organization" },
reference_prefix: "MSO",
time_zone: "Hawaii",
default_locale: "en",
@@ -48,7 +48,7 @@ module Decidim::Admin
command.call
organization.reload
- expect(organization.name).not_to eq("My super organization")
+ expect(translated(organization.name)).not_to eq("My super organization")
end
end
@@ -74,7 +74,7 @@ module Decidim::Admin
expect { command.call }.to broadcast(:ok)
organization.reload
- expect(organization.name).to eq("My super organization")
+ expect(translated(organization.name)).to eq("My super organization")
expect(organization.rich_text_editor_in_public_views).to be(true)
expect(organization.enable_machine_translations).to be(true)
end
diff --git a/decidim-admin/spec/forms/organization_form_spec.rb b/decidim-admin/spec/forms/base_organization_form_spec.rb
similarity index 98%
rename from decidim-admin/spec/forms/organization_form_spec.rb
rename to decidim-admin/spec/forms/base_organization_form_spec.rb
index b5da645503de7..91a32cf2e0179 100644
--- a/decidim-admin/spec/forms/organization_form_spec.rb
+++ b/decidim-admin/spec/forms/base_organization_form_spec.rb
@@ -11,7 +11,7 @@ module Admin
)
end
- let(:name) { "My super organization" }
+ let(:name) { { ca: "", en: "My super organization", es: "" } }
let(:reference_prefix) { "MSO" }
let(:time_zone) { "UTC" }
let(:twitter_handler) { "My twitter awesome handler" }
diff --git a/decidim-api/app/views/decidim/api/documentation/show.html.erb b/decidim-api/app/views/decidim/api/documentation/show.html.erb
index a6367c1a8fbaf..f1b0a9cae7df0 100644
--- a/decidim-api/app/views/decidim/api/documentation/show.html.erb
+++ b/decidim-api/app/views/decidim/api/documentation/show.html.erb
@@ -1,7 +1,7 @@
Decidim <%= Decidim.version %>
-
<%= current_organization.name %> API documentation
+
<%= current_organization_name %> API documentation
<% if defined?(graphiql_path) %>
<%= link_to "Explore the API interactively with GraphiQL", graphiql_path %>
<% end %>
diff --git a/decidim-api/app/views/layouts/decidim/api/documentation.html.erb b/decidim-api/app/views/layouts/decidim/api/documentation.html.erb
index 29eba32fa7fd8..c26265c72d850 100644
--- a/decidim-api/app/views/layouts/decidim/api/documentation.html.erb
+++ b/decidim-api/app/views/layouts/decidim/api/documentation.html.erb
@@ -1,6 +1,6 @@
-
<%= current_organization.name %> - API Documentation
+
<%= current_organization_name %> - API Documentation
<%= stylesheet_pack_tag("decidim_api_docs") %>
diff --git a/decidim-api/spec/system/documentation_spec.rb b/decidim-api/spec/system/documentation_spec.rb
index d995788b278b8..0680b00503695 100644
--- a/decidim-api/spec/system/documentation_spec.rb
+++ b/decidim-api/spec/system/documentation_spec.rb
@@ -14,7 +14,7 @@
visit decidim_api.documentation_path
within "h1" do
- expect(page).to have_content(organization.name)
+ expect(page).to have_content(translated(organization.name))
end
expect(page).to have_content("About the GraphQL API")
end
diff --git a/decidim-blogs/app/helpers/decidim/blogs/admin/posts_helper.rb b/decidim-blogs/app/helpers/decidim/blogs/admin/posts_helper.rb
index 206bcabbeb102..96fe9d3990f69 100644
--- a/decidim-blogs/app/helpers/decidim/blogs/admin/posts_helper.rb
+++ b/decidim-blogs/app/helpers/decidim/blogs/admin/posts_helper.rb
@@ -22,7 +22,7 @@ def post_description_admin(post, max_length = 100)
def post_author_select_field(form, name, _options = {})
select_options = [
- [current_organization.name, ""],
+ [current_organization_name, ""],
[current_user.name, current_user.id]
]
current_user_groups = Decidim::UserGroups::ManageableUserGroups.for(current_user).verified
diff --git a/decidim-blogs/app/views/decidim/blogs/admin/posts/index.html.erb b/decidim-blogs/app/views/decidim/blogs/admin/posts/index.html.erb
index af173981775e5..6c571e9eb4463 100644
--- a/decidim-blogs/app/views/decidim/blogs/admin/posts/index.html.erb
+++ b/decidim-blogs/app/views/decidim/blogs/admin/posts/index.html.erb
@@ -33,7 +33,7 @@
<%= decidim_sanitize_editor post_description_admin(post) %>
- <%= post.try(:author).try(:name) %>
+ <%= translated_attribute(post.try(:author).try(:name)) %>
|
<% publish_data = publish_data(post.published_at) %>
diff --git a/decidim-blogs/spec/helpers/decidim/blogs/admin/post_helper_spec.rb b/decidim-blogs/spec/helpers/decidim/blogs/admin/post_helper_spec.rb
index 94226f441770b..2506adef8739f 100644
--- a/decidim-blogs/spec/helpers/decidim/blogs/admin/post_helper_spec.rb
+++ b/decidim-blogs/spec/helpers/decidim/blogs/admin/post_helper_spec.rb
@@ -20,7 +20,7 @@ module Decidim::Blogs::Admin
let(:all_fields) do
[
- [organization.name, ""],
+ [translated(organization.name), ""],
[user.name, user.id],
[user_group.name, user_group.id]
]
@@ -28,7 +28,7 @@ module Decidim::Blogs::Admin
let(:extra_user_fields) do
[
- [organization.name, ""],
+ [translated(organization.name), ""],
[user.name, user.id],
[user_group.name, user_group.id],
[another_user.name, another_user.id]
@@ -37,7 +37,7 @@ module Decidim::Blogs::Admin
let(:extra_group_fields) do
[
- [organization.name, ""],
+ [translated(organization.name), ""],
[user.name, user.id],
[user_group.name, user_group.id],
[another_user_group.name, another_user_group.id]
@@ -46,7 +46,7 @@ module Decidim::Blogs::Admin
let(:basic_fields) do
[
- [organization.name, ""],
+ [translated(organization.name), ""],
[user.name, user.id]
]
end
diff --git a/decidim-blogs/spec/shared/manage_posts_examples.rb b/decidim-blogs/spec/shared/manage_posts_examples.rb
index 38c5afa6de593..5c4e363393c58 100644
--- a/decidim-blogs/spec/shared/manage_posts_examples.rb
+++ b/decidim-blogs/spec/shared/manage_posts_examples.rb
@@ -15,7 +15,7 @@
end
within ".edit_post" do
- expect(page).to have_select("post_decidim_author_id", selected: author.name)
+ expect(page).to have_select("post_decidim_author_id", selected: translated(author.name))
fill_in_i18n(
:post_title,
@@ -40,7 +40,7 @@
within "table" do
expect(page).to have_content("My new title")
expect(page).to have_content("Post title 2")
- expect(page).to have_content(author.name)
+ expect(page).to have_content(translated(author.name))
end
end
@@ -158,7 +158,7 @@
it "can set organization as posts author" do
click_on "New post"
- select organization.name, from: "post_decidim_author_id"
+ select translated(organization.name), from: "post_decidim_author_id"
fill_in_i18n(
:post_title,
@@ -183,7 +183,7 @@
expect(page).to have_admin_callout("successfully")
within "table" do
- expect(page).to have_content(author.name)
+ expect(page).to have_content(translated(organization.name))
expect(page).to have_content("My post")
expect(page).to have_content("Post title 1")
expect(page).to have_content("Post title 2")
@@ -196,14 +196,14 @@
end
within ".edit_post" do
- select organization.name, from: "post_decidim_author_id"
+ select translated(organization.name), from: "post_decidim_author_id"
find("*[type=submit]").click
end
expect(page).to have_admin_callout("successfully")
within "tr", text: translated(post1.title) do
- expect(page).to have_content(author.name)
+ expect(page).to have_content(translated(organization.name))
end
end
end
diff --git a/decidim-blogs/spec/system/explore_posts_spec.rb b/decidim-blogs/spec/system/explore_posts_spec.rb
index 443e51db913e9..44f3f2ea1e276 100644
--- a/decidim-blogs/spec/system/explore_posts_spec.rb
+++ b/decidim-blogs/spec/system/explore_posts_spec.rb
@@ -112,7 +112,7 @@
it "show post info" do
expect(page).to have_i18n_content(post.title)
expect(page).to have_i18n_content(post.body)
- expect(page).to have_content(post.author.name)
+ expect(page).to have_content(translated(post.author.name))
expect(page).to have_content(post.created_at.strftime("%d/%m/%Y %H:%M"))
end
diff --git a/decidim-blogs/spec/types/integration_schema_spec.rb b/decidim-blogs/spec/types/integration_schema_spec.rb
index cfb058eee54ff..6f8f0e83a89d5 100644
--- a/decidim-blogs/spec/types/integration_schema_spec.rb
+++ b/decidim-blogs/spec/types/integration_schema_spec.rb
@@ -29,7 +29,7 @@
"id" => endo.author.id.to_s,
"name" => endo.author.name,
"nickname" => "@#{endo.author.nickname}",
- "organizationName" => endo.author.organization.name,
+ "organizationName" => { "translation" => translated(endo.author.organization.name) },
"profilePath" => "/profiles/#{endo.author.nickname}"
}
end,
@@ -98,7 +98,7 @@
deleted
name
nickname
- organizationName
+ organizationName { translation(locale:"#{locale}") }
profilePath
__typename
}
@@ -278,7 +278,7 @@
deleted
name
nickname
- organizationName
+ organizationName { translation(locale:"#{locale}") }
profilePath
__typename
}
diff --git a/decidim-budgets/spec/mailers/decidim/budgets/order_summary_mailer_spec.rb b/decidim-budgets/spec/mailers/decidim/budgets/order_summary_mailer_spec.rb
index 46add71a955e3..54917fc6dcb7e 100644
--- a/decidim-budgets/spec/mailers/decidim/budgets/order_summary_mailer_spec.rb
+++ b/decidim-budgets/spec/mailers/decidim/budgets/order_summary_mailer_spec.rb
@@ -19,7 +19,7 @@ module Decidim::Budgets
end
it "includes the organization data" do
- expect(mail.body.encoded).to include(user.organization.name)
+ expect(mail.body.encoded).to include(translated(user.organization.name))
end
it "includes the budget title" do
diff --git a/decidim-budgets/spec/system/orders_spec.rb b/decidim-budgets/spec/system/orders_spec.rb
index 642165c304900..b39a890afa513 100644
--- a/decidim-budgets/spec/system/orders_spec.rb
+++ b/decidim-budgets/spec/system/orders_spec.rb
@@ -305,7 +305,7 @@
expect(page).to have_content "€25,000,000"
- page.find("header a", text: organization.name).click
+ page.find("header a", text: translated(organization.name)).click
expect(page).to have_content "You have not yet voted"
diff --git a/decidim-conferences/app/views/decidim/conferences/admin/invite_join_conference_mailer/invite.html.erb b/decidim-conferences/app/views/decidim/conferences/admin/invite_join_conference_mailer/invite.html.erb
index 25dccb02ac011..9deb89650b5a6 100644
--- a/decidim-conferences/app/views/decidim/conferences/admin/invite_join_conference_mailer/invite.html.erb
+++ b/decidim-conferences/app/views/decidim/conferences/admin/invite_join_conference_mailer/invite.html.erb
@@ -1,7 +1,7 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @user.name) %>
- <%= t ".invited_existing_user_to_join_a_conference", invited_by: @invited_by.name, application: @user.organization.name %>
+ <%= t ".invited_existing_user_to_join_a_conference", invited_by: @invited_by.name, application: organization_name(@user.organization) %>
diff --git a/decidim-conferences/app/views/devise/mailer/join_conference.html.erb b/decidim-conferences/app/views/devise/mailer/join_conference.html.erb
index 02f5a1d9f4579..2bb89ddacaed0 100644
--- a/decidim-conferences/app/views/devise/mailer/join_conference.html.erb
+++ b/decidim-conferences/app/views/devise/mailer/join_conference.html.erb
@@ -1,7 +1,7 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.name) %>
- <%= t("decidim.conferences.admin.invite_join_conference_mailer.invite.invited_user_to_join_a_conference", invited_by: @resource.invited_by.name, application: @resource.organization.name) %>
+ <%= t("decidim.conferences.admin.invite_join_conference_mailer.invite.invited_user_to_join_a_conference", invited_by: @resource.invited_by.name, application: organization_name(@user.organization)) %>
<%= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, invitation_token: @token, invite_redirect: Decidim::EngineRouter.main_proxy(@opts[:conference]).conference_registration_type_conference_registration_path(conference_slug: @opts[:conference], registration_type_id: @opts[:registration_type]), host: @resource.organization.host) %>
diff --git a/decidim-conferences/app/views/devise/mailer/join_conference.text.erb b/decidim-conferences/app/views/devise/mailer/join_conference.text.erb
index 7de23b44a2957..453545bd3a54d 100644
--- a/decidim-conferences/app/views/devise/mailer/join_conference.text.erb
+++ b/decidim-conferences/app/views/devise/mailer/join_conference.text.erb
@@ -1,6 +1,6 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.name) %>
-<%= t("decidim.conferences.admin.invite_join_conference_mailer.invite.invited_existing_user_to_join_a_conference", invited_by: @resource.invited_by.name, application: @resource.organization.name) %>
+<%= t("decidim.conferences.admin.invite_join_conference_mailer.invite.invited_existing_user_to_join_a_conference", invited_by: @resource.invited_by.name, application: organization_name(@user.organization)) %>
<%= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, invitation_token: @token, invite_redirect: Decidim::EngineRouter.main_proxy(@opts[:conference]).conference_registration_type_conference_registration_path(conference_slug: @opts[:conference], registration_type_id: @opts[:registration_type]), host: @resource.organization.host) %>
diff --git a/decidim-core/app/cells/decidim/content_blocks/footer_sub_hero/show.erb b/decidim-core/app/cells/decidim/content_blocks/footer_sub_hero/show.erb
index 05792e12b1eb7..aad342d17c23d 100644
--- a/decidim-core/app/cells/decidim/content_blocks/footer_sub_hero/show.erb
+++ b/decidim-core/app/cells/decidim/content_blocks/footer_sub_hero/show.erb
@@ -1,7 +1,7 @@
diff --git a/decidim-core/app/cells/decidim/content_blocks/stats/show.erb b/decidim-core/app/cells/decidim/content_blocks/stats/show.erb
index 2b81899ad08cd..0b53bc559487c 100644
--- a/decidim-core/app/cells/decidim/content_blocks/stats/show.erb
+++ b/decidim-core/app/cells/decidim/content_blocks/stats/show.erb
@@ -1,6 +1,6 @@
- <%= t("decidim.pages.home.statistics.headline", organization: current_organization.name) %>
+ <%= t("decidim.pages.home.statistics.headline", organization: current_organization_name) %>
<%= cell("decidim/statistics", stats.highlighted + stats.not_highlighted) %>
diff --git a/decidim-core/app/cells/decidim/newsletter_templates/basic_only_text/show.erb b/decidim-core/app/cells/decidim/newsletter_templates/basic_only_text/show.erb
index e5d7578db4e7c..f2bb9bc120177 100644
--- a/decidim-core/app/cells/decidim/newsletter_templates/basic_only_text/show.erb
+++ b/decidim-core/app/cells/decidim/newsletter_templates/basic_only_text/show.erb
@@ -62,9 +62,9 @@
<% if custom_url_for_mail_root.present? %>
- <%= link_to organization.name.html_safe, custom_url_for_mail_root %>
+ <%= link_to organization_name(organization).html_safe, custom_url_for_mail_root %>
<% else %>
- <%= link_to organization.name.html_safe, decidim.root_url(host: organization.host) %>
+ <%= link_to organization_name(organization).html_safe, decidim.root_url(host: organization.host) %>
<% end %>
|
diff --git a/decidim-core/app/cells/decidim/newsletter_templates/image_text_cta/show.erb b/decidim-core/app/cells/decidim/newsletter_templates/image_text_cta/show.erb
index b85d85c2104a6..cb1f9ed7bb2ec 100644
--- a/decidim-core/app/cells/decidim/newsletter_templates/image_text_cta/show.erb
+++ b/decidim-core/app/cells/decidim/newsletter_templates/image_text_cta/show.erb
@@ -101,9 +101,9 @@ table.button table td {
<% if custom_url_for_mail_root.present? %>
- <%= link_to organization.name.html_safe, custom_url_for_mail_root %>
+ <%= link_to organization_name(organization).html_safe, custom_url_for_mail_root %>
<% else %>
- <%= link_to organization.name.html_safe, decidim.root_url(host: organization.host) %>
+ <%= link_to organization_name(organization).html_safe, decidim.root_url(host: organization.host) %>
<% end %>
|
diff --git a/decidim-core/app/cells/decidim/pad_iframe/show.erb b/decidim-core/app/cells/decidim/pad_iframe/show.erb
index 8ce2389c18c67..7cff5330d34b5 100644
--- a/decidim-core/app/cells/decidim/pad_iframe/show.erb
+++ b/decidim-core/app/cells/decidim/pad_iframe/show.erb
@@ -8,7 +8,7 @@
src="<%= iframe_url %>"
style="border: solid 4px #fff; border-radius: 4px; box-shadow: 0 0 0 1px #e8e8e8; width: 100%; height: 600px">
- <%= t("decidim.pad_iframe.disclaimer", organization: current_organization.name) %>
+ <%= t("decidim.pad_iframe.disclaimer", organization: current_organization_name) %>
diff --git a/decidim-core/app/cells/decidim/report_button/flag_modal.erb b/decidim-core/app/cells/decidim/report_button/flag_modal.erb
index b7d1b981b5c81..5dff59d7d98ed 100644
--- a/decidim-core/app/cells/decidim/report_button/flag_modal.erb
+++ b/decidim-core/app/cells/decidim/report_button/flag_modal.erb
@@ -10,7 +10,7 @@
<%= f.collection_radio_buttons :reason, [
[:spam, t("decidim.shared.flag_modal.spam")],
[:offensive, t("decidim.shared.flag_modal.offensive")],
- [:does_not_belong, t("decidim.shared.flag_modal.does_not_belong", organization_name: current_organization.name)]
+ [:does_not_belong, t("decidim.shared.flag_modal.does_not_belong", organization_name: current_organization_name)]
], :first, :last do |builder|
builder.label(for: nil, class: "form__wrapper-checkbox-label") { builder.radio_button(id: nil) + builder.text }
end %>
diff --git a/decidim-core/app/controllers/concerns/decidim/payload_info.rb b/decidim-core/app/controllers/concerns/decidim/payload_info.rb
index c9adfac3fe518..cdb768b5149bf 100644
--- a/decidim-core/app/controllers/concerns/decidim/payload_info.rb
+++ b/decidim-core/app/controllers/concerns/decidim/payload_info.rb
@@ -5,13 +5,14 @@
module Decidim
module PayloadInfo
extend ActiveSupport::Concern
+ include Decidim::TranslatableAttributes
included do
def append_info_to_payload(payload)
super
payload[:user_id] = try(:current_user).try(:id)
payload[:organization_id] = try(:current_organization).try(:id)
- payload[:app] = try(:current_organization).try(:name)
+ payload[:app] = translated_attribute(try(:current_organization).try(:name))
payload[:remote_ip] = request.remote_ip
payload[:referer] = request.referer.to_s
payload[:request_id] = request.uuid
diff --git a/decidim-core/app/events/decidim/welcome_notification_event.rb b/decidim-core/app/events/decidim/welcome_notification_event.rb
index b5ee5994955ba..42188a17eb2cd 100644
--- a/decidim-core/app/events/decidim/welcome_notification_event.rb
+++ b/decidim-core/app/events/decidim/welcome_notification_event.rb
@@ -44,7 +44,7 @@ def resource_title
def interpolate(template)
template
.gsub("{{name}}", user.name)
- .gsub("{{organization}}", organization.name)
+ .gsub("{{organization}}", organization_name(organization))
.gsub("{{help_url}}", url_helpers.pages_url(host: organization.host))
.gsub("{{badges_url}}", url_helpers.gamification_badges_url(host: organization.host))
.html_safe
diff --git a/decidim-core/app/helpers/decidim/layout_helper.rb b/decidim-core/app/helpers/decidim/layout_helper.rb
index 458e494f62657..52c3262571ef7 100644
--- a/decidim-core/app/helpers/decidim/layout_helper.rb
+++ b/decidim-core/app/helpers/decidim/layout_helper.rb
@@ -3,6 +3,7 @@
module Decidim
# View helpers related to the layout.
module LayoutHelper
+ include Decidim::OrganizationHelper
include Decidim::ModalHelper
include Decidim::TooltipHelper
@@ -129,28 +130,6 @@ def extended_navigation_bar(items, max_items: 5)
}
end
- # Renders a view with the customizable CSS variables in two flavours:
- # 1. as a hexadecimal valid CSS color (ie: #ff0000)
- # 2. as a disassembled RGB components (ie: 255 0 0)
- #
- # Example:
- #
- # --primary: #ff0000;
- # --primary-rgb: 255 0 0
- #
- # Hexadecimal variables can be used as a normal CSS color:
- #
- # color: var(--primary)
- #
- # While the disassembled variant can be used where you need to manipulate
- # the color somehow (ie: adding a background transparency):
- #
- # background-color: rgba(var(--primary-rgb), 0.5)
- def organization_colors
- css = current_organization.colors.each.map { |k, v| "--#{k}: #{v};--#{k}-rgb: #{v[1..2].hex} #{v[3..4].hex} #{v[5..6].hex};" }.join
- render partial: "layouts/decidim/organization_colors", locals: { css: }
- end
-
def current_user_unread_data
return {} if current_user.blank?
@@ -161,22 +140,8 @@ def current_user_unread_data
end
end
- def organization_description_label
- @organization_description_label ||= if empty_organization_description?
- t("decidim.pages.home.footer_sub_hero.footer_sub_hero_body_html")
- else
- decidim_sanitize_admin(translated_attribute(current_organization.description))
- end
- end
-
private
- def empty_organization_description?
- organization_description = translated_attribute(current_organization.description)
-
- organization_description.blank? || organization_description == ""
- end
-
def tag_builder
@tag_builder ||= ActionView::Helpers::TagHelper::TagBuilder.new(self)
end
diff --git a/decidim-core/app/helpers/decidim/organization_helper.rb b/decidim-core/app/helpers/decidim/organization_helper.rb
new file mode 100644
index 0000000000000..722929c0eb703
--- /dev/null
+++ b/decidim-core/app/helpers/decidim/organization_helper.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+module Decidim
+ # View helpers related to the organization.
+
+ module OrganizationHelper
+ include Decidim::TranslatableAttributes
+
+ # Renders a view with the customizable CSS variables in two flavours:
+ # 1. as a hexadecimal valid CSS color (ie: #ff0000)
+ # 2. as a disassembled RGB components (ie: 255 0 0)
+ #
+ # Example:
+ #
+ # --primary: #ff0000;
+ # --primary-rgb: 255 0 0
+ #
+ # Hexadecimal variables can be used as a normal CSS color:
+ #
+ # color: var(--primary)
+ #
+ # While the disassembled variant can be used where you need to manipulate
+ # the color somehow (ie: adding a background transparency):
+ #
+ # background-color: rgba(var(--primary-rgb), 0.5)
+ def organization_colors
+ css = current_organization.colors.each.map { |k, v| "--#{k}: #{v};--#{k}-rgb: #{v[1..2].hex} #{v[3..4].hex} #{v[5..6].hex};" }.join
+ render partial: "layouts/decidim/organization_colors", locals: { css: }
+ end
+
+ def organization_description_label
+ @organization_description_label ||= if empty_organization_description?
+ t("decidim.pages.home.footer_sub_hero.footer_sub_hero_body_html")
+ else
+ decidim_sanitize_admin(translated_attribute(current_organization.description))
+ end
+ end
+
+ def organization_name(organization = current_organization)
+ translated_attribute(organization.name, organization)
+ end
+
+ def current_organization_name
+ organization_name(current_organization)
+ end
+
+ private
+
+ def empty_organization_description?
+ organization_description = translated_attribute(current_organization.description)
+
+ organization_description.blank? || organization_description == ""
+ end
+ end
+end
diff --git a/decidim-core/app/mailers/decidim/application_mailer.rb b/decidim-core/app/mailers/decidim/application_mailer.rb
index f334811eec2a3..3a6c5cc79adcd 100644
--- a/decidim-core/app/mailers/decidim/application_mailer.rb
+++ b/decidim-core/app/mailers/decidim/application_mailer.rb
@@ -6,6 +6,10 @@ module Decidim
class ApplicationMailer < ActionMailer::Base
include LocalisedMailer
include MultitenantAssetHost
+ include Decidim::SanitizeHelper
+ include Decidim::OrganizationHelper
+ helper_method :organization_name, :decidim_escape_translated, :decidim_sanitize_translated, :translated_attribute, :decidim_sanitize, :decidim_sanitize_newsletter
+
after_action :set_smtp
after_action :set_from
@@ -44,11 +48,11 @@ def sender
smtp_settings_from = organization.smtp_settings["from"]
return smtp_settings_from if already_defined_name_in_mail?(smtp_settings_from)
- email_address_with_name(smtp_settings_from, organization.name)
+ email_address_with_name(smtp_settings_from, organization_name(organization))
end
def default_sender
- email_address_with_name(Decidim.config.mailer_sender, organization.name)
+ email_address_with_name(Decidim.config.mailer_sender, organization_name(organization))
end
def already_defined_name_in_mail?(mail_address)
diff --git a/decidim-core/app/mailers/decidim/block_user_mailer.rb b/decidim-core/app/mailers/decidim/block_user_mailer.rb
index 5591246e03b0c..142d367a87781 100644
--- a/decidim-core/app/mailers/decidim/block_user_mailer.rb
+++ b/decidim-core/app/mailers/decidim/block_user_mailer.rb
@@ -11,7 +11,7 @@ def notify(user, justification)
@justification = justification
subject = I18n.t(
"decidim.block_user_mailer.notify.subject",
- organization_name: @organization.name,
+ organization_name: organization_name(@organization),
justification: @justification
)
diff --git a/decidim-core/app/mailers/decidim/decidim_devise_mailer.rb b/decidim-core/app/mailers/decidim/decidim_devise_mailer.rb
index fcbd26a9401c5..48e04822f3842 100644
--- a/decidim-core/app/mailers/decidim/decidim_devise_mailer.rb
+++ b/decidim-core/app/mailers/decidim/decidim_devise_mailer.rb
@@ -5,6 +5,8 @@ module Decidim
# each role and use a localised version.
class DecidimDeviseMailer < ::Devise::Mailer
include LocalisedMailer
+ include Decidim::SanitizeHelper
+ helper_method :decidim_escape_translated, :decidim_sanitize_translated, :translated_attribute
layout "decidim/mailer"
@@ -19,7 +21,11 @@ def invitation_instructions(user, token, opts = {})
@organization = user.organization
@opts = opts
- opts[:subject] = I18n.t("devise.mailer.#{opts[:invitation_instructions]}.subject", organization: user.organization.name) if opts[:invitation_instructions]
+ if opts[:invitation_instructions]
+ opts[:subject] =
+ I18n.t("devise.mailer.#{opts[:invitation_instructions]}.subject",
+ organization: organization_name(user.organization))
+ end
end
devise_mail(user, opts[:invitation_instructions] || :invitation_instructions, opts)
diff --git a/decidim-core/app/mailers/decidim/newsletter_mailer.rb b/decidim-core/app/mailers/decidim/newsletter_mailer.rb
index cee715ed79a16..72b8ca59450ac 100644
--- a/decidim-core/app/mailers/decidim/newsletter_mailer.rb
+++ b/decidim-core/app/mailers/decidim/newsletter_mailer.rb
@@ -2,9 +2,6 @@
module Decidim
class NewsletterMailer < ApplicationMailer
- helper Decidim::SanitizeHelper
- helper Decidim::TranslationsHelper
-
include Decidim::NewslettersHelper
layout "decidim/newsletter_base"
diff --git a/decidim-core/app/mailers/decidim/newsletters_opt_in_mailer.rb b/decidim-core/app/mailers/decidim/newsletters_opt_in_mailer.rb
index 81e2e65733bb1..e5e0020c0be7b 100644
--- a/decidim-core/app/mailers/decidim/newsletters_opt_in_mailer.rb
+++ b/decidim-core/app/mailers/decidim/newsletters_opt_in_mailer.rb
@@ -10,7 +10,7 @@ def notify(user, token)
@organization = user.organization
@token = token
- mail(to: user.email, subject: I18n.t("decidim.newsletters_opt_in_mailer.notify.subject", organization_name: @organization.name))
+ mail(to: user.email, subject: I18n.t("decidim.newsletters_opt_in_mailer.notify.subject", organization_name: organization_name(@organization)))
end
end
end
diff --git a/decidim-core/app/mailers/decidim/notification_mailer.rb b/decidim-core/app/mailers/decidim/notification_mailer.rb
index c9060132614fa..c744280fcf075 100644
--- a/decidim-core/app/mailers/decidim/notification_mailer.rb
+++ b/decidim-core/app/mailers/decidim/notification_mailer.rb
@@ -5,7 +5,6 @@ module Decidim
# a events are received.
class NotificationMailer < Decidim::ApplicationMailer
helper Decidim::ResourceHelper
- helper Decidim::SanitizeHelper
def event_received(event, event_class_name, resource, user, user_role, extra) # rubocop:disable Metrics/ParameterLists
with_user(user) do
diff --git a/decidim-core/app/mailers/decidim/notifications_digest_mailer.rb b/decidim-core/app/mailers/decidim/notifications_digest_mailer.rb
index 53d14210b6df5..62c5b6792fe57 100644
--- a/decidim-core/app/mailers/decidim/notifications_digest_mailer.rb
+++ b/decidim-core/app/mailers/decidim/notifications_digest_mailer.rb
@@ -5,7 +5,6 @@ module Decidim
# a events are received.
class NotificationsDigestMailer < Decidim::ApplicationMailer
helper Decidim::ResourceHelper
- helper Decidim::SanitizeHelper
SIZE_LIMIT = 10
def digest_mail(user, notification_ids)
diff --git a/decidim-core/app/mailers/decidim/reported_mailer.rb b/decidim-core/app/mailers/decidim/reported_mailer.rb
index 5bb27a75ca0a7..d3aaa937395fd 100644
--- a/decidim-core/app/mailers/decidim/reported_mailer.rb
+++ b/decidim-core/app/mailers/decidim/reported_mailer.rb
@@ -4,7 +4,6 @@ module Decidim
# A custom mailer for sending notifications to an admin when a report is created.
class ReportedMailer < Decidim::ApplicationMailer
helper Decidim::ResourceHelper
- helper Decidim::TranslationsHelper
helper_method :reported_content_url, :report_url, :manage_moderations_url, :author_profile_url, :reported_content_cell
diff --git a/decidim-core/app/mailers/decidim/user_report_mailer.rb b/decidim-core/app/mailers/decidim/user_report_mailer.rb
index 59377fb899834..c2334aecc0e08 100644
--- a/decidim-core/app/mailers/decidim/user_report_mailer.rb
+++ b/decidim-core/app/mailers/decidim/user_report_mailer.rb
@@ -11,7 +11,7 @@ def notify(admin, report)
with_user(admin) do
mail(to: admin.email, subject: I18n.t(
"decidim.user_report_mailer.notify.subject",
- organization_name: report.moderation.user.organization.name,
+ organization_name: organization_name(report.moderation.user.organization),
reason: @report.reason
))
end
diff --git a/decidim-core/app/models/decidim/organization.rb b/decidim-core/app/models/decidim/organization.rb
index 893eb956a7d63..9215737ddf4ef 100644
--- a/decidim-core/app/models/decidim/organization.rb
+++ b/decidim-core/app/models/decidim/organization.rb
@@ -15,7 +15,7 @@ class Organization < ApplicationRecord
SOCIAL_HANDLERS = [:twitter, :facebook, :instagram, :youtube, :github].freeze
AVAILABLE_MACHINE_TRANSLATION_DISPLAY_PRIORITIES = %w(original translation).freeze
- translatable_fields :description, :cta_button_text, :omnipresent_banner_title, :omnipresent_banner_short_description,
+ translatable_fields :name, :description, :cta_button_text, :omnipresent_banner_title, :omnipresent_banner_short_description,
:highlighted_content_banner_title, :highlighted_content_banner_short_description, :highlighted_content_banner_action_title,
:highlighted_content_banner_action_subtitle, :welcome_notification_subject, :welcome_notification_body, :id_documents_explanation_text,
:admin_terms_of_service_body
@@ -41,7 +41,7 @@ class Organization < ApplicationRecord
# disable: Users cannot register or sign in.
enum users_registration_mode: [:enabled, :existing, :disabled], _prefix: true
- validates :name, :host, uniqueness: true
+ validates :host, uniqueness: true
validates :reference_prefix, presence: true
validates :time_zone, presence: true, time_zone: true
validates :default_locale, inclusion: { in: :available_locales }
@@ -60,6 +60,27 @@ class Organization < ApplicationRecord
has_one_attached :open_data_file
+ validate :unique_name
+
+ def unique_name
+ base_query = new_record? ? Decidim::Organization.all : Decidim::Organization.where.not(id:).all
+
+ organization_names = []
+
+ base_query.pluck(:name).each do |value|
+ organization_names += value.except("machine_translations").values
+ organization_names += value.fetch("machine_translations", {}).values
+ end
+
+ organization_names = organization_names.map(&:downcase).compact_blank
+
+ name.each do |language, value|
+ next if value.is_a?(Hash)
+
+ errors.add("name_#{language}", :taken) if organization_names.include?(value.downcase)
+ end
+ end
+
def self.log_presenter_class_for(_log)
Decidim::AdminLog::OrganizationPresenter
end
diff --git a/decidim-core/app/presenters/decidim/organization_presenter.rb b/decidim-core/app/presenters/decidim/organization_presenter.rb
index fd275dd3bd93a..1b542a8afdb70 100644
--- a/decidim-core/app/presenters/decidim/organization_presenter.rb
+++ b/decidim-core/app/presenters/decidim/organization_presenter.rb
@@ -4,7 +4,7 @@ module Decidim
# A general presenter to render organization logic to build a manifest
class OrganizationPresenter < SimpleDelegator
def html_name
- name.html_safe
+ translated_attribute(name).html_safe
end
def translated_description
diff --git a/decidim-core/app/views/decidim/block_user_mailer/notify.html.erb b/decidim-core/app/views/decidim/block_user_mailer/notify.html.erb
index 230a4e9b5ad18..ed0ec06fb7207 100644
--- a/decidim-core/app/views/decidim/block_user_mailer/notify.html.erb
+++ b/decidim-core/app/views/decidim/block_user_mailer/notify.html.erb
@@ -1,7 +1,7 @@
<%= t ".hello" %>
-<%= t ".body_1", organization_name: h(@organization.name) %>
+<%= t ".body_1", organization_name: organization_name(@organization) %>
<%= t ".body_2", justification: h(@justification) %>
-<%= t(".greetings", organization_name: h(@organization.name), organization_url: decidim.root_url(host: @organization.host)).html_safe %>
+<%= t(".greetings", organization_name: organization_name(@organization), organization_url: decidim.root_url(host: @organization.host)).html_safe %>
diff --git a/decidim-core/app/views/decidim/devise/invitations/edit.html.erb b/decidim-core/app/views/decidim/devise/invitations/edit.html.erb
index 265b15674a805..37b3ddad15556 100644
--- a/decidim-core/app/views/decidim/devise/invitations/edit.html.erb
+++ b/decidim-core/app/views/decidim/devise/invitations/edit.html.erb
@@ -14,7 +14,7 @@
<%= f.hidden_field :invitation_token %>
- <%= f.text_field :nickname, help_text: t("devise.invitations.edit.nickname_help", organization: current_organization.name), required: "required", autocomplete: "nickname" %>
+ <%= f.text_field :nickname, help_text: t("devise.invitations.edit.nickname_help", organization: current_organization_name), required: "required", autocomplete: "nickname" %>
<% if f.object.class.require_password_on_accepting %>
<%= render partial: "decidim/account/password_fields", locals: { form: f, user: :user } %>
diff --git a/decidim-core/app/views/decidim/devise/omniauth_registrations/new.html.erb b/decidim-core/app/views/decidim/devise/omniauth_registrations/new.html.erb
index d70f83672100f..9565e5089ecd9 100644
--- a/decidim-core/app/views/decidim/devise/omniauth_registrations/new.html.erb
+++ b/decidim-core/app/views/decidim/devise/omniauth_registrations/new.html.erb
@@ -18,7 +18,7 @@
<%= f.text_field :name, help_text: t("decidim.devise.omniauth_registrations.new.username_help"), autocomplete: "name", placeholder: "John Doe" %>
- <%= f.text_field :nickname, help_text: t("decidim.devise.omniauth_registrations.new.nickname_help", organization: current_organization.name), autocomplete: "nickname", placeholder: "johndoe" %>
+ <%= f.text_field :nickname, help_text: t("decidim.devise.omniauth_registrations.new.nickname_help", organization: current_organization_name), autocomplete: "nickname", placeholder: "johndoe" %>
<%= f.email_field :email, autocomplete: "email", placeholder: t("placeholder_email", scope: "decidim.devise.shared") %>
diff --git a/decidim-core/app/views/decidim/doorkeeper/authorizations/new.html.erb b/decidim-core/app/views/decidim/doorkeeper/authorizations/new.html.erb
index 5b95a35da23af..c1acab5045da7 100644
--- a/decidim-core/app/views/decidim/doorkeeper/authorizations/new.html.erb
+++ b/decidim-core/app/views/decidim/doorkeeper/authorizations/new.html.erb
@@ -8,7 +8,7 @@
- <%= t("connect_your_account_html", scope: "decidim.doorkeeper.authorizations.new", organization: current_organization.name) %>
+ <%= t("connect_your_account_html", scope: "decidim.doorkeeper.authorizations.new", organization: current_organization_name) %>
<%= t("this_application_will_be_able_to", scope: "decidim.doorkeeper.authorizations.new") %>
diff --git a/decidim-core/app/views/decidim/gamification/badges/index.html.erb b/decidim-core/app/views/decidim/gamification/badges/index.html.erb
index aabdaa2afffae..e04ac22bb720a 100644
--- a/decidim-core/app/views/decidim/gamification/badges/index.html.erb
+++ b/decidim-core/app/views/decidim/gamification/badges/index.html.erb
@@ -23,7 +23,7 @@
<%= t ".badge_title", name: badge.translated_name %>
- <%= badge.description(current_organization.name) %>
+ <%= badge.description(current_organization_name) %>
<%= t ".how" %>
diff --git a/decidim-core/app/views/decidim/newsletter_mailer/newsletter.html.erb b/decidim-core/app/views/decidim/newsletter_mailer/newsletter.html.erb
index e44032337ee44..98c548c48eb95 100644
--- a/decidim-core/app/views/decidim/newsletter_mailer/newsletter.html.erb
+++ b/decidim-core/app/views/decidim/newsletter_mailer/newsletter.html.erb
@@ -1,7 +1,7 @@
<%= decidim_sanitize_newsletter cell.to_s %>
<% content_for :note do %>
- <%== t ".note", organization_name: h(@organization.name), link: @newsletter.notifications_settings_url %>
+ <%== t ".note", organization_name: organization_name(@organization), link: @newsletter.notifications_settings_url %>
<% end %>
<% content_for :unsubscribe do %>
diff --git a/decidim-core/app/views/decidim/newsletters/show.html.erb b/decidim-core/app/views/decidim/newsletters/show.html.erb
index 4ffca31c5412b..bd810345d8dab 100644
--- a/decidim-core/app/views/decidim/newsletters/show.html.erb
+++ b/decidim-core/app/views/decidim/newsletters/show.html.erb
@@ -8,7 +8,7 @@
<%= decidim_sanitize_newsletter @cell.to_s %>
<% content_for :note do %>
- <%== t "note", scope: "decidim.newsletter_mailer.newsletter", organization_name: h(@organization.name), link: decidim.notifications_settings_url(host: @organization.host) %>
+ <%== t "note", scope: "decidim.newsletter_mailer.newsletter", organization_name: current_organization_name, link: decidim.notifications_settings_url(host: @organization.host) %>
<% end %>
<% if @user.present? %>
diff --git a/decidim-core/app/views/decidim/newsletters_opt_in_mailer/notify.html.erb b/decidim-core/app/views/decidim/newsletters_opt_in_mailer/notify.html.erb
index fc2f1ab9fce99..f25b186ff43e7 100644
--- a/decidim-core/app/views/decidim/newsletters_opt_in_mailer/notify.html.erb
+++ b/decidim-core/app/views/decidim/newsletters_opt_in_mailer/notify.html.erb
@@ -1,6 +1,6 @@
<%= t ".hello" %>
- <%= t ".body_1", organization_name: h(@organization.name) %>
+ <%= t ".body_1", organization_name: organization_name(@organization) %>
<%= t ".body_2" %>
@@ -20,4 +20,4 @@
<%= t ".body_3" %>
- <%= t(".greetings", organization_name: h(@organization.name), organization_url: decidim.root_url(host: @organization.host)).html_safe %>
+ <%= t(".greetings", organization_name: organization_name(@organization), organization_url: decidim.root_url(host: @organization.host)).html_safe %>
diff --git a/decidim-core/app/views/decidim/pages/index.html.erb b/decidim-core/app/views/decidim/pages/index.html.erb
index 255c8749e7a2c..e2e3b53cd6b8a 100644
--- a/decidim-core/app/views/decidim/pages/index.html.erb
+++ b/decidim-core/app/views/decidim/pages/index.html.erb
@@ -13,7 +13,7 @@ edit_link(
<%= t "decidim.pages.index.title" %>
- <%= t("decidim.pages.index.subheading", name: current_organization.name) %>
+ <%= t("decidim.pages.index.subheading", name: current_organization_name) %>
diff --git a/decidim-core/app/views/decidim/reported_mailer/report.html.erb b/decidim-core/app/views/decidim/reported_mailer/report.html.erb
index 306bb62235e66..701a3c48c9e79 100644
--- a/decidim-core/app/views/decidim/reported_mailer/report.html.erb
+++ b/decidim-core/app/views/decidim/reported_mailer/report.html.erb
@@ -13,7 +13,7 @@
<%= link_to translated_attribute(@participatory_space.title), resource_locator(@participatory_space).url %>
<%= t(".reason") %>
- <%= t(@report.reason, organization_name: @participatory_space.organization.name, scope: "decidim.shared.flag_modal") %>
+ <%= t(@report.reason, organization_name: organization_name(@participatory_space.organization), scope: "decidim.shared.flag_modal") %>
<% if @report.details.present? %>
<%= t(".details") %>
@@ -37,7 +37,9 @@
<% else %>
<%=
- if @author.respond_to?(:name)
+ if @author.is_a?(Decidim::Organization)
+ organization_name(@author)
+ elsif @author.respond_to?(:name)
@author.name
elsif @author.respond_to?(:title)
translated_attribute(@author.title)
diff --git a/decidim-core/app/views/decidim/user_report_mailer/notify.html.erb b/decidim-core/app/views/decidim/user_report_mailer/notify.html.erb
index d3aad1353df87..bb078a6f68eb8 100644
--- a/decidim-core/app/views/decidim/user_report_mailer/notify.html.erb
+++ b/decidim-core/app/views/decidim/user_report_mailer/notify.html.erb
@@ -2,7 +2,7 @@
<%= t ".body_1", user: h(@report.moderation.user.name), token: h(@report.user.name) %>
- <%= t ".body_2", reason: t(@report.reason, organization_name: @report.moderation.user.organization.name, scope: "decidim.shared.flag_user_modal") %>
+ <%= t ".body_2", reason: t(@report.reason, organization_name: organization_name(@report.moderation.user.organization), scope: "decidim.shared.flag_user_modal") %>
<% if @report.details.present? %>
<%= t(".details") %>
@@ -11,4 +11,4 @@
<% end %>
- <%= t(".greetings", organization_name: h(@report.moderation.user.organization.name), organization_url: decidim.root_url(host: @report.moderation.user.organization.host)).html_safe %>
+ <%= t(".greetings", organization_name: organization_name(@report.moderation.user.organization), organization_url: decidim.root_url(host: @report.moderation.user.organization.host)).html_safe %>
diff --git a/decidim-core/app/views/decidim/user_update_mailer/notify.html.erb b/decidim-core/app/views/decidim/user_update_mailer/notify.html.erb
index 7915502c211fa..4e099d7dbbb19 100644
--- a/decidim-core/app/views/decidim/user_update_mailer/notify.html.erb
+++ b/decidim-core/app/views/decidim/user_update_mailer/notify.html.erb
@@ -6,4 +6,4 @@
<%= t ".body_2" %>
- <%= t(".greetings", organization_name: h(@organization.name), organization_url: decidim.root_url(host: @organization.host)).html_safe %>
+ <%= t(".greetings", organization_name: organization_name(@organization), organization_url: decidim.root_url(host: @organization.host)).html_safe %>
diff --git a/decidim-core/app/views/devise/mailer/invitation_instructions.html.erb b/decidim-core/app/views/devise/mailer/invitation_instructions.html.erb
index e518af3508f8d..6b0da4e6b237d 100644
--- a/decidim-core/app/views/devise/mailer/invitation_instructions.html.erb
+++ b/decidim-core/app/views/devise/mailer/invitation_instructions.html.erb
@@ -1,7 +1,7 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.name) %>
- <%= t("devise.mailer.invitation_instructions.someone_invited_you", application: @resource.organization.name) %>
+ <%= t("devise.mailer.invitation_instructions.someone_invited_you", application: organization_name(@resource.organization)) %>
<%= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, invitation_token: @token, invite_redirect: decidim.root_path, host: @resource.organization.host) %>
diff --git a/decidim-core/app/views/devise/mailer/invitation_instructions.text.erb b/decidim-core/app/views/devise/mailer/invitation_instructions.text.erb
index 33887fcf34677..151078176dc43 100644
--- a/decidim-core/app/views/devise/mailer/invitation_instructions.text.erb
+++ b/decidim-core/app/views/devise/mailer/invitation_instructions.text.erb
@@ -1,6 +1,6 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.name) %>
-<%= t("devise.mailer.invitation_instructions.someone_invited_you", application: @resource.organization.name) %>
+<%= t("devise.mailer.invitation_instructions.someone_invited_you", application: organization_name(@resource.organization)) %>
<%= accept_invitation_url(@resource, invitation_token: @token, invite_redirect: decidim.root_path, host: @resource.organization.host) %>
diff --git a/decidim-core/app/views/devise/mailer/invite_admin.html.erb b/decidim-core/app/views/devise/mailer/invite_admin.html.erb
index d0733210c7e4f..3a660c0884767 100644
--- a/decidim-core/app/views/devise/mailer/invite_admin.html.erb
+++ b/decidim-core/app/views/devise/mailer/invite_admin.html.erb
@@ -2,9 +2,9 @@
<% if @resource.invited_by.present? %>
- <%= t("devise.mailer.invitation_instructions.invited_you_as_admin", invited_by: @resource.invited_by.name, application: @resource.organization.name) %>
+ <%= t("devise.mailer.invitation_instructions.invited_you_as_admin", invited_by: @resource.invited_by.name, application: organization_name(@resource.organization)) %>
<% else %>
- <%= t("devise.mailer.invitation_instructions.someone_invited_you_as_admin", application: @resource.organization.name) %>
+ <%= t("devise.mailer.invitation_instructions.someone_invited_you_as_admin", application: organization_name(@resource.organization)) %>
<% end %>
diff --git a/decidim-core/app/views/devise/mailer/invite_admin.text.erb b/decidim-core/app/views/devise/mailer/invite_admin.text.erb
index 2da16effaec97..52775b1aed59c 100644
--- a/decidim-core/app/views/devise/mailer/invite_admin.text.erb
+++ b/decidim-core/app/views/devise/mailer/invite_admin.text.erb
@@ -1,9 +1,9 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.name) %>
<% if @resource.invited_by.present? %>
-<%= t("devise.mailer.invitation_instructions.invited_you_as_admin", invited_by: @resource.invited_by.name, application: @resource.organization.name) %>
+<%= t("devise.mailer.invitation_instructions.invited_you_as_admin", invited_by: @resource.invited_by.name, application: organization_name(@resource.organization)) %>
<% else %>
-<%= t("devise.mailer.invitation_instructions.someone_invited_you_as_admin", application: @resource.organization.name) %>
+<%= t("devise.mailer.invitation_instructions.someone_invited_you_as_admin", application: organization_name(@resource.organization)) %>
<% end %>
<%= accept_invitation_url(@resource, invitation_token: @token, invite_redirect: decidim_admin.root_path, host: @resource.organization.host) %>
diff --git a/decidim-core/app/views/devise/mailer/invite_collaborator.html.erb b/decidim-core/app/views/devise/mailer/invite_collaborator.html.erb
index d0733210c7e4f..3a660c0884767 100644
--- a/decidim-core/app/views/devise/mailer/invite_collaborator.html.erb
+++ b/decidim-core/app/views/devise/mailer/invite_collaborator.html.erb
@@ -2,9 +2,9 @@
<% if @resource.invited_by.present? %>
- <%= t("devise.mailer.invitation_instructions.invited_you_as_admin", invited_by: @resource.invited_by.name, application: @resource.organization.name) %>
+ <%= t("devise.mailer.invitation_instructions.invited_you_as_admin", invited_by: @resource.invited_by.name, application: organization_name(@resource.organization)) %>
<% else %>
- <%= t("devise.mailer.invitation_instructions.someone_invited_you_as_admin", application: @resource.organization.name) %>
+ <%= t("devise.mailer.invitation_instructions.someone_invited_you_as_admin", application: organization_name(@resource.organization)) %>
<% end %>
diff --git a/decidim-core/app/views/devise/mailer/invite_collaborator.text.erb b/decidim-core/app/views/devise/mailer/invite_collaborator.text.erb
index 2da16effaec97..52775b1aed59c 100644
--- a/decidim-core/app/views/devise/mailer/invite_collaborator.text.erb
+++ b/decidim-core/app/views/devise/mailer/invite_collaborator.text.erb
@@ -1,9 +1,9 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.name) %>
<% if @resource.invited_by.present? %>
-<%= t("devise.mailer.invitation_instructions.invited_you_as_admin", invited_by: @resource.invited_by.name, application: @resource.organization.name) %>
+<%= t("devise.mailer.invitation_instructions.invited_you_as_admin", invited_by: @resource.invited_by.name, application: organization_name(@resource.organization)) %>
<% else %>
-<%= t("devise.mailer.invitation_instructions.someone_invited_you_as_admin", application: @resource.organization.name) %>
+<%= t("devise.mailer.invitation_instructions.someone_invited_you_as_admin", application: organization_name(@resource.organization)) %>
<% end %>
<%= accept_invitation_url(@resource, invitation_token: @token, invite_redirect: decidim_admin.root_path, host: @resource.organization.host) %>
diff --git a/decidim-core/app/views/devise/mailer/invite_private_user.html.erb b/decidim-core/app/views/devise/mailer/invite_private_user.html.erb
index 3b5e9029e09c1..3694d05a6827d 100644
--- a/decidim-core/app/views/devise/mailer/invite_private_user.html.erb
+++ b/decidim-core/app/views/devise/mailer/invite_private_user.html.erb
@@ -2,9 +2,9 @@
<% if @resource.invited_by.present? %>
- <%= t("devise.mailer.invitation_instructions.invited_you_as_private_user", invited_by: @resource.invited_by.name, application: @resource.organization.name) %>
+ <%= t("devise.mailer.invitation_instructions.invited_you_as_private_user", invited_by: @resource.invited_by.name, application: organization_name(@resource.organization)) %>
<% else %>
- <%= t("devise.mailer.invitation_instructions.someone_invited_you_as_private_user", application: @resource.organization.name) %>
+ <%= t("devise.mailer.invitation_instructions.someone_invited_you_as_private_user", application: organization_name(@resource.organization)) %>
<% end %>
diff --git a/decidim-core/app/views/devise/mailer/invite_private_user.text.erb b/decidim-core/app/views/devise/mailer/invite_private_user.text.erb
index e34ff1d366585..8f572859214a1 100644
--- a/decidim-core/app/views/devise/mailer/invite_private_user.text.erb
+++ b/decidim-core/app/views/devise/mailer/invite_private_user.text.erb
@@ -1,9 +1,9 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.name) %>
<% if @resource.invited_by.present? %>
-<%= t("devise.mailer.invitation_instructions.invited_you_as_private_user", invited_by: @resource.invited_by.name, application: @resource.organization.name) %>
+<%= t("devise.mailer.invitation_instructions.invited_you_as_private_user", invited_by: @resource.invited_by.name, application: organization_name(@resource.organization)) %>
<% else %>
-<%= t("devise.mailer.invitation_instructions.someone_invited_you_as_private_user", application: @resource.organization.name) %>
+<%= t("devise.mailer.invitation_instructions.someone_invited_you_as_private_user", application: organization_name(@resource.organization)) %>
<% end %>
<%= accept_invitation_url(@resource, invitation_token: @token, host: @resource.organization.host) %>
diff --git a/decidim-core/app/views/devise/mailer/organization_admin_invitation_instructions.html.erb b/decidim-core/app/views/devise/mailer/organization_admin_invitation_instructions.html.erb
index 68198d936fb5a..4c1de528295ac 100644
--- a/decidim-core/app/views/devise/mailer/organization_admin_invitation_instructions.html.erb
+++ b/decidim-core/app/views/devise/mailer/organization_admin_invitation_instructions.html.erb
@@ -1,6 +1,6 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.email) %>
- <%= t("devise.mailer.invitation_instructions.someone_invited_you", application: @resource.organization.name) %>
+ <%= t("devise.mailer.invitation_instructions.someone_invited_you", application: organization_name(@resource.organization)) %>
<%= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, invitation_token: @token, invite_redirect: decidim_admin.root_path, host: @resource.organization.host) %>
diff --git a/decidim-core/app/views/devise/mailer/organization_admin_invitation_instructions.text.erb b/decidim-core/app/views/devise/mailer/organization_admin_invitation_instructions.text.erb
index 26d0644bb6c75..812882ca2802e 100644
--- a/decidim-core/app/views/devise/mailer/organization_admin_invitation_instructions.text.erb
+++ b/decidim-core/app/views/devise/mailer/organization_admin_invitation_instructions.text.erb
@@ -1,6 +1,6 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.email) %>
-<%= t("devise.mailer.invitation_instructions.someone_invited_you", application: @resource.organization.name) %>
+<%= t("devise.mailer.invitation_instructions.someone_invited_you", application: organization_name(@resource.organization)) %>
<%= accept_invitation_url(@resource, invitation_token: @token, invite_redirect: decidim_admin.root_path, host: @resource.organization.host) %>
diff --git a/decidim-core/app/views/layouts/decidim/_logo.html.erb b/decidim-core/app/views/layouts/decidim/_logo.html.erb
index 539fab122601d..e1b0ccaa1c868 100644
--- a/decidim-core/app/views/layouts/decidim/_logo.html.erb
+++ b/decidim-core/app/views/layouts/decidim/_logo.html.erb
@@ -1,9 +1,9 @@
<% if organization %>
<%= link_to decidim.root_url(host: organization.host), "aria-label": t("front_page_link", scope: "decidim.accessibility") do %>
<% if organization.logo.attached? %>
- <%= image_tag organization.attached_uploader(:logo).variant_path(:medium), alt: t("logo", scope: "decidim.accessibility", organization: organization.name) %>
+ <%= image_tag organization.attached_uploader(:logo).variant_path(:medium), alt: t("logo", scope: "decidim.accessibility", organization: current_organization_name) %>
<% else %>
- <%= organization.name %>
+ <%= current_organization_name %>
<% end %>
<% end %>
<% else %>
diff --git a/decidim-core/app/views/layouts/decidim/_mailer_logo.html.erb b/decidim-core/app/views/layouts/decidim/_mailer_logo.html.erb
index ae5c7f4a70ea9..105bd94463566 100644
--- a/decidim-core/app/views/layouts/decidim/_mailer_logo.html.erb
+++ b/decidim-core/app/views/layouts/decidim/_mailer_logo.html.erb
@@ -9,10 +9,10 @@
<%= image_tag(
organization.attached_uploader(:logo).variant_url(:medium, host: organization.host),
style: "max-height: 50px",
- alt: "#{organization.name}"
+ alt: organization_name(organization)
) %>
<% else %>
- <%= organization.name %>
+ <%= organization_name(organization) %>
<% end %>
<% end %>
<% else %>
diff --git a/decidim-core/app/views/layouts/decidim/_meta_tags_config.html.erb b/decidim-core/app/views/layouts/decidim/_meta_tags_config.html.erb
index 73b0152564945..69725992dc4be 100644
--- a/decidim-core/app/views/layouts/decidim/_meta_tags_config.html.erb
+++ b/decidim-core/app/views/layouts/decidim/_meta_tags_config.html.erb
@@ -1,6 +1,6 @@
<% add_decidim_meta_tags({
description: strip_tags(translated_attribute(current_organization.description)),
- title: current_organization.name,
+ title: current_organization_name,
url: request.original_url,
twitter_handler: current_organization.twitter_handler,
image_url: Decidim::ContentBlock.published.find_by(
diff --git a/decidim-core/app/views/layouts/decidim/footer/_main_intro.html.erb b/decidim-core/app/views/layouts/decidim/footer/_main_intro.html.erb
index 783804d77e1eb..1bd2fada7cd76 100644
--- a/decidim-core/app/views/layouts/decidim/footer/_main_intro.html.erb
+++ b/decidim-core/app/views/layouts/decidim/footer/_main_intro.html.erb
@@ -1,9 +1,9 @@
<% if current_organization.official_img_footer.attached? %>
<%= link_to current_organization.official_url, class: "block mb-6" do %>
- <%= image_tag current_organization.attached_uploader(:official_img_footer).path, alt: current_organization.name, class: "max-h-16" %>
+ <%= image_tag current_organization.attached_uploader(:official_img_footer).path, alt: current_organization_name, class: "max-h-16" %>
<% end %>
<% end %>
- <%= t("decidim.pages.home.footer_sub_hero.footer_sub_hero_headline", organization: current_organization.name) %>
+ <%= t("decidim.pages.home.footer_sub_hero.footer_sub_hero_headline", organization: current_organization_name) %>
<%= organization_description_label %>
diff --git a/decidim-core/app/views/layouts/decidim/footer/_main_social_media_links.html.erb b/decidim-core/app/views/layouts/decidim/footer/_main_social_media_links.html.erb
index c7b86f444c8c8..7e6a8e52cfaf4 100644
--- a/decidim-core/app/views/layouts/decidim/footer/_main_social_media_links.html.erb
+++ b/decidim-core/app/views/layouts/decidim/footer/_main_social_media_links.html.erb
@@ -2,7 +2,7 @@
<% if current_organization.twitter_handler.present? %>
- <%= t("layouts.decidim.social_media_links.x", organization: translated_attribute(current_organization.name)) %>
+ <%= t("layouts.decidim.social_media_links.x", organization: current_organization_name) %>
<%= icon "twitter-x-line", class: "w-8 h-8 fill-current", "aria-label": "X" %>
@@ -10,7 +10,7 @@
<% if current_organization.facebook_handler.present? %>
- <%= t("layouts.decidim.social_media_links.facebook", organization: translated_attribute(current_organization.name)) %>
+ <%= t("layouts.decidim.social_media_links.facebook", organization: current_organization_name) %>
<%= icon "facebook-fill", class: "w-8 h-8 fill-current", "aria-label": "Facebook" %>
@@ -18,7 +18,7 @@
<% if current_organization.instagram_handler.present? %>
- <%= t("layouts.decidim.social_media_links.instagram", organization: translated_attribute(current_organization.name)) %>
+ <%= t("layouts.decidim.social_media_links.instagram", organization: current_organization_name) %>
<%= icon "instagram-line", class: "w-8 h-8 fill-current", "aria-label": "Instagram" %>
@@ -26,7 +26,7 @@
<% if current_organization.youtube_handler.present? %>
- <%= t("layouts.decidim.social_media_links.youtube", organization: translated_attribute(current_organization.name)) %>
+ <%= t("layouts.decidim.social_media_links.youtube", organization: current_organization_name) %>
<%= icon "youtube-line", class: "w-8 h-8 fill-current", "aria-label": "YouTube" %>
@@ -34,7 +34,7 @@
<% if current_organization.github_handler.present? %>
- <%= t("layouts.decidim.social_media_links.github", organization: translated_attribute(current_organization.name)) %>
+ <%= t("layouts.decidim.social_media_links.github", organization: current_organization_name) %>
<%= icon "github-fill", class: "w-8 h-8 fill-current", "aria-label": "GitHub" %>
diff --git a/decidim-core/app/views/layouts/decidim/header/_menu_breadcrumb_main_dropdown_top_left.html.erb b/decidim-core/app/views/layouts/decidim/header/_menu_breadcrumb_main_dropdown_top_left.html.erb
index 5267087180a90..f7dde44f3d1ba 100644
--- a/decidim-core/app/views/layouts/decidim/header/_menu_breadcrumb_main_dropdown_top_left.html.erb
+++ b/decidim-core/app/views/layouts/decidim/header/_menu_breadcrumb_main_dropdown_top_left.html.erb
@@ -1,2 +1,2 @@
- <%= t("decidim.pages.home.footer_sub_hero.footer_sub_hero_headline", organization: current_organization.name) %>
+ <%= t("decidim.pages.home.footer_sub_hero.footer_sub_hero_headline", organization: current_organization_name) %>
<%= organization_description_label %>
diff --git a/decidim-core/app/views/layouts/decidim/mailer.html.erb b/decidim-core/app/views/layouts/decidim/mailer.html.erb
index 87b5f9d7899f4..c51fa305838b1 100644
--- a/decidim-core/app/views/layouts/decidim/mailer.html.erb
+++ b/decidim-core/app/views/layouts/decidim/mailer.html.erb
@@ -83,9 +83,9 @@
<% if @custom_url_for_mail_root.present? %>
- <%= link_to @organization.name.html_safe, @custom_url_for_mail_root %>
+ <%= link_to organization_name(@organization).html_safe, @custom_url_for_mail_root %>
<% else %>
- <%= link_to @organization.name.html_safe, decidim.root_url(host: @organization.host) %>
+ <%= link_to organization_name(@organization).html_safe, decidim.root_url(host: @organization.host) %>
<% end %>
|
diff --git a/decidim-core/db/migrate/20240401192628_change_name_on_decidim_organizations.rb b/decidim-core/db/migrate/20240401192628_change_name_on_decidim_organizations.rb
new file mode 100644
index 0000000000000..f2d2f5abb01f3
--- /dev/null
+++ b/decidim-core/db/migrate/20240401192628_change_name_on_decidim_organizations.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class ChangeNameOnDecidimOrganizations < ActiveRecord::Migration[6.1]
+ class Organization < ApplicationRecord
+ self.table_name = :decidim_organizations
+ end
+
+ def up
+ rename_column :decidim_organizations, :name, :old_name
+ add_column :decidim_organizations, :name, :jsonb, null: false, default: {}
+
+ Organization.reset_column_information
+
+ Organization.find_each do |organization|
+ organization.update(name: { organization.default_locale => organization.old_name })
+ end
+ remove_column :decidim_organizations, :old_name
+ end
+
+ def down
+ rename_column :decidim_organizations, :name, :old_name
+ add_column :decidim_organizations, :name, :string, null: false, default: ""
+
+ Organization.reset_column_information
+
+ Organization.find_each do |organization|
+ organization.update(name: organization.old_name[organization.default_locale])
+ end
+ remove_column :decidim_organizations, :old_name
+ end
+end
diff --git a/decidim-core/lib/decidim/api/interfaces/author_interface.rb b/decidim-core/lib/decidim/api/interfaces/author_interface.rb
index 7c6ad1653b8c8..a82aad94742fe 100644
--- a/decidim-core/lib/decidim/api/interfaces/author_interface.rb
+++ b/decidim-core/lib/decidim/api/interfaces/author_interface.rb
@@ -15,7 +15,7 @@ module AuthorInterface
field :avatar_url, String, "The author's avatar url", null: false
field :profile_path, String, "The author's profile path", null: false
field :badge, String, "The author's badge icon", null: false
- field :organization_name, String, "The authors's organization name", null: false
+ field :organization_name, Decidim::Core::TranslatedFieldType, "The authors's organization name", null: false
def organization_name
object.organization.name
diff --git a/decidim-core/lib/decidim/api/types/organization_type.rb b/decidim-core/lib/decidim/api/types/organization_type.rb
index 42836d71df294..daab328d62677 100644
--- a/decidim-core/lib/decidim/api/types/organization_type.rb
+++ b/decidim-core/lib/decidim/api/types/organization_type.rb
@@ -5,7 +5,7 @@ module Core
class OrganizationType < Decidim::Api::Types::BaseObject
description "The current organization"
- field :name, GraphQL::Types::String, "The name of the current organization", null: true
+ field :name, Decidim::Core::TranslatedFieldType, "The name of the current organization", null: true
field :stats, [Core::StatisticType, { null: true }], description: "The statistics associated to this object", null: true
diff --git a/decidim-core/lib/decidim/api/types/user_group_type.rb b/decidim-core/lib/decidim/api/types/user_group_type.rb
index 2e9b1d7ebb593..3e94a4fbbf5e0 100644
--- a/decidim-core/lib/decidim/api/types/user_group_type.rb
+++ b/decidim-core/lib/decidim/api/types/user_group_type.rb
@@ -30,7 +30,7 @@ def profile_path
object.presenter.profile_path
end
- field :organization_name, GraphQL::Types::String, "The user group's organization name", null: false
+ field :organization_name, Decidim::Core::TranslatedFieldType, "The user group's organization name", null: false
def organization_name
object.organization.name
diff --git a/decidim-core/lib/decidim/api/types/user_type.rb b/decidim-core/lib/decidim/api/types/user_type.rb
index e6649bf1f5723..1795653040a53 100644
--- a/decidim-core/lib/decidim/api/types/user_type.rb
+++ b/decidim-core/lib/decidim/api/types/user_type.rb
@@ -23,7 +23,7 @@ class UserType < Decidim::Api::Types::BaseObject
description: ["If the user making the request is logged in, it will return whether this recipient accepts a conversation or not.",
" It will return false for non-logged requests."].join
- field :organization_name, GraphQL::Types::String, "The user's organization name", null: false
+ field :organization_name, Decidim::Core::TranslatedFieldType, "The user's organization name", null: false
field :deleted, GraphQL::Types::Boolean, "Whether the user's account has been deleted or not", null: false
diff --git a/decidim-core/lib/decidim/authorable.rb b/decidim-core/lib/decidim/authorable.rb
index a704bbff8aa88..970c14517468b 100644
--- a/decidim-core/lib/decidim/authorable.rb
+++ b/decidim-core/lib/decidim/authorable.rb
@@ -7,6 +7,7 @@ module Decidim
# this latest case the Coauthorable concern should be used instead of Authorable.
module Authorable
extend ActiveSupport::Concern
+ include Decidim::TranslatableAttributes
included do
belongs_to :author, polymorphic: true, foreign_key: "decidim_author_id", foreign_type: "decidim_author_type"
@@ -68,6 +69,10 @@ def official?
decidim_author_type == Decidim::Organization.name
end
+ def author_name
+ translated_attribute(normalized_author.name)
+ end
+
private
def verified_user_group
diff --git a/decidim-core/lib/decidim/core/seeds.rb b/decidim-core/lib/decidim/core/seeds.rb
index 0c9e726cc9466..a83d2eade5f14 100644
--- a/decidim-core/lib/decidim/core/seeds.rb
+++ b/decidim-core/lib/decidim/core/seeds.rb
@@ -124,7 +124,7 @@ def create_organization!
}
Decidim::Organization.first || Decidim::Organization.create!(
- name: ::Faker::Company.name,
+ name: Decidim::Faker::Localized.company,
twitter_handler: ::Faker::Hipster.word,
facebook_handler: ::Faker::Hipster.word,
instagram_handler: ::Faker::Hipster.word,
diff --git a/decidim-core/lib/decidim/core/test/factories.rb b/decidim-core/lib/decidim/core/test/factories.rb
index e550c087aaa29..0c735187ea13c 100644
--- a/decidim-core/lib/decidim/core/test/factories.rb
+++ b/decidim-core/lib/decidim/core/test/factories.rb
@@ -112,7 +112,11 @@ def generate_localized_title(field = nil, skip_injection: false)
create_static_pages { true }
end
- name { Faker::Company.unique.name }
+ # we do not want machine translation here
+ name do
+ Decidim.available_locales.index_with { |_locale| Faker::Company.unique.name }
+ end
+
reference_prefix { Faker::Name.suffix }
time_zone { "UTC" }
twitter_handler { Faker::Hipster.word }
diff --git a/decidim-core/lib/decidim/core/test/shared_examples/logo_email.rb b/decidim-core/lib/decidim/core/test/shared_examples/logo_email.rb
index 41ef089f78657..44739a5cb401c 100644
--- a/decidim-core/lib/decidim/core/test/shared_examples/logo_email.rb
+++ b/decidim-core/lib/decidim/core/test/shared_examples/logo_email.rb
@@ -5,7 +5,7 @@
shared_examples "email with logo" do
context "when organization has a logo" do
let(:organization_logo) { Decidim::Dev.test_file("city.jpeg", "image/jpeg") }
- let(:organization) { create(:organization, name: "O'Higgins", logo: organization_logo) }
+ let(:organization) { create(:organization, name: { en: "O'Higgins" }, logo: organization_logo) }
let(:mail) { described_class.event_received(event, event_class_name, resource, user, :follower, extra) }
let(:logo_path) { Rails.application.routes.url_helpers.rails_representation_path(organization.logo.variant(resize_to_fit: [600, 160]), only_path: true) }
diff --git a/decidim-core/lib/decidim/download_your_data_serializers/download_your_data_user_serializer.rb b/decidim-core/lib/decidim/download_your_data_serializers/download_your_data_user_serializer.rb
index ec8048065db63..79552cc5da91d 100644
--- a/decidim-core/lib/decidim/download_your_data_serializers/download_your_data_user_serializer.rb
+++ b/decidim-core/lib/decidim/download_your_data_serializers/download_your_data_user_serializer.rb
@@ -5,6 +5,7 @@ module Decidim
module DownloadYourDataSerializers
class DownloadYourDataUserSerializer < Decidim::Exporters::Serializer
include Decidim::ResourceHelper
+ include Decidim::TranslatableAttributes
# Public: Exports a hash with the serialized data for this user.
def serialize
@@ -16,7 +17,7 @@ def serialize
locale: resource.locale,
organization: {
id: resource.organization.try(:id),
- name: resource.organization.try(:name)
+ name: translated_attribute(resource.organization.try(:name))
},
newsletter_notifications_at: resource.newsletter_notifications_at,
notifications_sending_frequency: resource.notifications_sending_frequency,
diff --git a/decidim-core/lib/decidim/events/simple_event.rb b/decidim-core/lib/decidim/events/simple_event.rb
index a8e202dc6c591..c8f8b527f7f8c 100644
--- a/decidim-core/lib/decidim/events/simple_event.rb
+++ b/decidim-core/lib/decidim/events/simple_event.rb
@@ -11,6 +11,7 @@ class SimpleEvent < BaseEvent
include Decidim::Events::EmailEvent
include Decidim::Events::NotificationEvent
include Decidim::ComponentPathHelper
+ include Decidim::OrganizationHelper
delegate :created_at, to: :resource
diff --git a/decidim-core/lib/tasks/decidim_metrics_tasks.rake b/decidim-core/lib/tasks/decidim_metrics_tasks.rake
index e06d15ae901b5..b9c01d5398d31 100644
--- a/decidim-core/lib/tasks/decidim_metrics_tasks.rake
+++ b/decidim-core/lib/tasks/decidim_metrics_tasks.rake
@@ -47,10 +47,10 @@ namespace :decidim do
Decidim::Organization.find_each do |organization|
if metric
m_manifest = Decidim.metrics_registry.for(metric)
- log_info "[#{organization.name}]: rebuilding metric [#{metric}] for day [#{current_day}]"
+ log_info "[#{organization.name[organization.default_locale.to_s]}]: rebuilding metric [#{metric}] for day [#{current_day}]"
call_metric_job(m_manifest, organization, current_day)
else
- log_info "[#{organization.name}]: rebuilding all metrics for day [#{current_day}]"
+ log_info "[#{organization.name[organization.default_locale.to_s]}]: rebuilding all metrics for day [#{current_day}]"
Decidim.metrics_registry.all.each do |metric_manifest|
call_metric_job(metric_manifest, organization, current_day)
end
diff --git a/decidim-core/spec/cells/decidim/content_blocks/hero_cell_spec.rb b/decidim-core/spec/cells/decidim/content_blocks/hero_cell_spec.rb
index e8ce7e666f5a9..69dbe2da4a491 100644
--- a/decidim-core/spec/cells/decidim/content_blocks/hero_cell_spec.rb
+++ b/decidim-core/spec/cells/decidim/content_blocks/hero_cell_spec.rb
@@ -13,7 +13,7 @@
context "when the content block has no settings" do
it "shows the default welcome text" do
- expect(subject).to have_text("Welcome to #{organization.name}")
+ expect(subject).to have_text("Welcome to #{translated(organization.name)}")
end
end
@@ -70,7 +70,7 @@
context "when organization is updated" do
it "generates a different hash" do
old_hash = cell(content_block.cell, content_block).send(:cache_hash)
- controller.current_organization.update!(name: "New name")
+ controller.current_organization.update!(name: { en: "New name" })
controller.current_organization.reload
expect(cell(content_block.cell, content_block).send(:cache_hash)).not_to eq(old_hash)
diff --git a/decidim-core/spec/controllers/manifests_controller_spec.rb b/decidim-core/spec/controllers/manifests_controller_spec.rb
index 56073c73bd9dc..fe78101fe4c55 100644
--- a/decidim-core/spec/controllers/manifests_controller_spec.rb
+++ b/decidim-core/spec/controllers/manifests_controller_spec.rb
@@ -6,7 +6,7 @@ module Decidim
describe ManifestsController do
routes { Decidim::Core::Engine.routes }
- let(:organization) { create(:organization, name: "Organization's name") }
+ let(:organization) { create(:organization, name: { en: "Organization's name" }) }
before do
Decidim::Organization.destroy_all
@@ -22,9 +22,9 @@ module Decidim
expect(response).to be_successful
manifest = JSON.parse(response.body)
- expect(manifest["name"]).to eq(organization.name)
+ expect(manifest["name"]).to eq(translated(organization.name))
expect(manifest["lang"]).to eq(organization.default_locale)
- expect(manifest["description"]).to eq(ActionView::Base.full_sanitizer.sanitize(organization.description["en"]))
+ expect(manifest["description"]).to eq(ActionView::Base.full_sanitizer.sanitize(translated(organization.description)))
expect(manifest["background_color"]).to eq("#e02d2d")
expect(manifest["theme_color"]).to eq("#e02d2d")
expect(manifest["display"]).to eq("standalone")
diff --git a/decidim-core/spec/events/decidim/welcome_notification_event_spec.rb b/decidim-core/spec/events/decidim/welcome_notification_event_spec.rb
index eebb888f39a89..07af83f29aa08 100644
--- a/decidim-core/spec/events/decidim/welcome_notification_event_spec.rb
+++ b/decidim-core/spec/events/decidim/welcome_notification_event_spec.rb
@@ -17,7 +17,7 @@
let(:organization) { create(:organization, name: organization_name) }
context "with a normal organization name" do
- let(:organization_name) { "My Organization" }
+ let(:organization_name) { { ca: "", en: "My Organization", es: "" } }
describe "#email_subject" do
subject { event_instance.email_subject }
@@ -33,7 +33,7 @@
end
context "with an organization with an apostrophe" do
- let(:organization_name) { "My ol'Organization" }
+ let(:organization_name) { { ca: "", en: "My ol'Organization", es: "" } }
describe "#email_subject" do
subject { event_instance.email_subject }
diff --git a/decidim-core/spec/lib/download_your_data_serializers/download_your_data_user_serializer_spec.rb b/decidim-core/spec/lib/download_your_data_serializers/download_your_data_user_serializer_spec.rb
index cfe6021832a27..e1238d4b0e936 100644
--- a/decidim-core/spec/lib/download_your_data_serializers/download_your_data_user_serializer_spec.rb
+++ b/decidim-core/spec/lib/download_your_data_serializers/download_your_data_user_serializer_spec.rb
@@ -35,7 +35,7 @@ module Decidim
include(id: resource.organization.id)
)
expect(serialized[:organization]).to(
- include(name: resource.organization.name)
+ include(name: translated(resource.organization.name))
)
end
diff --git a/decidim-core/spec/lib/events/email_event_spec.rb b/decidim-core/spec/lib/events/email_event_spec.rb
index ee96c19c4c8c7..37911ccbf1017 100644
--- a/decidim-core/spec/lib/events/email_event_spec.rb
+++ b/decidim-core/spec/lib/events/email_event_spec.rb
@@ -21,7 +21,7 @@ class TestEvent < Decidim::Events::BaseEvent
TestEvent.new(resource:, event_name: "test", user:)
end
- let(:organization) { create(:organization, name: "O'Connor") }
+ let(:organization) { create(:organization, name: { en: "O'Connor" }) }
let(:user) { create(:user, name: "Sarah Connor", organization:) }
let(:resource) { user }
diff --git a/decidim-core/spec/lib/query_extensions_spec.rb b/decidim-core/spec/lib/query_extensions_spec.rb
index aa0c1d5fe21c0..b3735bf2c7997 100644
--- a/decidim-core/spec/lib/query_extensions_spec.rb
+++ b/decidim-core/spec/lib/query_extensions_spec.rb
@@ -40,10 +40,10 @@ module Core
end
describe "organization" do
- let(:query) { %({ organization { name }}) }
+ let(:query) { %({ organization { name { translation(locale: "en") } }}) }
it "returns the current organization" do
- expect(response["organization"]["name"]).to eq(current_organization.name.to_s)
+ expect(response["organization"]["name"]["translation"]).to eq(translated(current_organization.name))
end
end
diff --git a/decidim-core/spec/lib/welcome_notification_event_spec.rb b/decidim-core/spec/lib/welcome_notification_event_spec.rb
index c2008ae97c650..63232c52b0fdb 100644
--- a/decidim-core/spec/lib/welcome_notification_event_spec.rb
+++ b/decidim-core/spec/lib/welcome_notification_event_spec.rb
@@ -6,7 +6,7 @@ module Decidim
describe WelcomeNotificationEvent do
subject { described_class.new(resource: user, event_name: "test", user:) }
let(:user) { create(:user, organization:, name: "James") }
- let(:organization) { create(:organization, name: "Awesome Town") }
+ let(:organization) { create(:organization, name: { en: "Awesome Town" }) }
describe "subject" do
it "has a default" do
@@ -49,7 +49,7 @@ module Decidim
end
context "when the organization has customized the default welcome message" do
- let(:organization) { create(:organization, name: "Awesome Town", welcome_notification_subject:, welcome_notification_body:) }
+ let(:organization) { create(:organization, name: { en: "Awesome Town" }, welcome_notification_subject:, welcome_notification_body:) }
let(:welcome_notification_subject) do
{ en: "Well hello {{name}}" }
end
diff --git a/decidim-core/spec/mailers/application_mailer_spec.rb b/decidim-core/spec/mailers/application_mailer_spec.rb
index 54349ad59f732..e2c850523951a 100644
--- a/decidim-core/spec/mailers/application_mailer_spec.rb
+++ b/decidim-core/spec/mailers/application_mailer_spec.rb
@@ -6,7 +6,7 @@ module Decidim
describe Decidim::Dev::DummyResourceMailer do
describe "smtp_settings" do
let(:user) { create(:user, organization:) }
- let(:organization) { create(:organization, name: "My Organization", smtp_settings:) }
+ let(:organization) { create(:organization, name: { en: "My Organization" }, smtp_settings:) }
let(:smtp_settings) do
{
"address" => "mail.example.org",
diff --git a/decidim-core/spec/mailers/block_user_mailer_spec.rb b/decidim-core/spec/mailers/block_user_mailer_spec.rb
index f9f9133a4a7d7..05c042e27c863 100644
--- a/decidim-core/spec/mailers/block_user_mailer_spec.rb
+++ b/decidim-core/spec/mailers/block_user_mailer_spec.rb
@@ -14,7 +14,7 @@ module Decidim
let(:mail) { described_class.notify(user, token) }
it "parses the subject" do
- expect(mail.subject).to eq("Your account was blocked by #{organization.name}")
+ expect(mail.subject).to eq("Your account was blocked by #{translated_attribute(organization.name)}")
end
it "parses the body" do
diff --git a/decidim-core/spec/mailers/decidim_devise_mailer_spec.rb b/decidim-core/spec/mailers/decidim_devise_mailer_spec.rb
index 330d0b64a5db6..9f1de622e9fc9 100644
--- a/decidim-core/spec/mailers/decidim_devise_mailer_spec.rb
+++ b/decidim-core/spec/mailers/decidim_devise_mailer_spec.rb
@@ -43,9 +43,13 @@ module Decidim
described_class.invitation_instructions(user, "foo", invitation_instructions: "organization_admin_invitation_instructions")
end
- let(:mail_subject) { "T'han convidat a administrar #{user.organization.name}" }
+ let(:mail_subject) do
+ I18n.with_locale(locale) do
+ "T'han convidat a administrar #{translated_attribute(user.organization.name)}"
+ end
+ end
let(:body) { "Acceptar invitaci" }
- let(:default_subject) { "You have been invited to manage #{user.organization.name}" }
+ let(:default_subject) { "You have been invited to manage #{translated_attribute(user.organization.name)}" }
let(:default_body) { "Accept invitation" }
include_examples "localised email"
diff --git a/decidim-core/spec/mailers/messaging/conversation_mailer_spec.rb b/decidim-core/spec/mailers/messaging/conversation_mailer_spec.rb
index 2a896ac199c51..ffa1b548d4b20 100644
--- a/decidim-core/spec/mailers/messaging/conversation_mailer_spec.rb
+++ b/decidim-core/spec/mailers/messaging/conversation_mailer_spec.rb
@@ -25,7 +25,7 @@ module Messaging
end
it "includes the organization data" do
- expect(subject.body).to include(user.organization.name)
+ expect(subject.body).to include(translated(user.organization.name))
end
it "includes the message" do
diff --git a/decidim-core/spec/mailers/newsletters_opt_in_mailer_spec.rb b/decidim-core/spec/mailers/newsletters_opt_in_mailer_spec.rb
index 5d6c47fd16ec7..cd1087ef47f86 100644
--- a/decidim-core/spec/mailers/newsletters_opt_in_mailer_spec.rb
+++ b/decidim-core/spec/mailers/newsletters_opt_in_mailer_spec.rb
@@ -13,7 +13,7 @@ module Decidim
let(:mail) { described_class.notify(user, token) }
it "parses the subject" do
- expect(mail.subject).to eq("Do you want to keep receiving relevant information about #{organization.name}?")
+ expect(mail.subject).to eq("Do you want to keep receiving relevant information about #{translated(organization.name)}?")
end
it "parses the body" do
diff --git a/decidim-core/spec/mailers/notification_digest_mailer_spec.rb b/decidim-core/spec/mailers/notification_digest_mailer_spec.rb
index a629c18815aa2..7f36293e4bcc9 100644
--- a/decidim-core/spec/mailers/notification_digest_mailer_spec.rb
+++ b/decidim-core/spec/mailers/notification_digest_mailer_spec.rb
@@ -4,7 +4,7 @@
module Decidim
describe NotificationsDigestMailer do
- let(:organization) { create(:organization, name: "O'Connor") }
+ let(:organization) { create(:organization) }
let(:user) { create(:user, name: "Sarah Connor", organization:) }
let(:notification_ids) { [notification.id] }
let(:notification) { create(:notification, user:, resource:) }
diff --git a/decidim-core/spec/mailers/notification_mailer_spec.rb b/decidim-core/spec/mailers/notification_mailer_spec.rb
index d4d8f51026c6a..d3cd353dff9f3 100644
--- a/decidim-core/spec/mailers/notification_mailer_spec.rb
+++ b/decidim-core/spec/mailers/notification_mailer_spec.rb
@@ -4,7 +4,7 @@
module Decidim
describe NotificationMailer do
- let(:organization) { create(:organization, name: "O'Connor") }
+ let(:organization) { create(:organization, name: { en: "O'Connor" }) }
let(:user) { create(:user, name: "Sarah Connor", organization:) }
let(:resource) { user }
let(:event_class_name) { "Decidim::ProfileUpdatedEvent" }
@@ -26,7 +26,7 @@ module Decidim
end
it "includes the organization data" do
- expect(mail.body.encoded).to include(user.organization.name)
+ expect(mail.body.encoded).to include(decidim_escape_translated(user.organization.name))
end
it "includes the greeting" do
diff --git a/decidim-core/spec/mailers/reported_mailer_spec.rb b/decidim-core/spec/mailers/reported_mailer_spec.rb
index 3fe1c1ab3a619..642e46b8a5df5 100644
--- a/decidim-core/spec/mailers/reported_mailer_spec.rb
+++ b/decidim-core/spec/mailers/reported_mailer_spec.rb
@@ -4,7 +4,7 @@
module Decidim
describe ReportedMailer do
- let(:organization) { create(:organization, name: "Test Organization") }
+ let(:organization) { create(:organization) }
let(:user) { create(:user, :admin, organization:) }
let(:component) { create(:component, organization:) }
let(:reportable) { create(:proposal, title: Decidim::Faker::Localized.sentence, body: Decidim::Faker::Localized.paragraph(sentence_count: 3)) }
@@ -14,7 +14,11 @@ module Decidim
let(:decidim) { Decidim::Core::Engine.routes.url_helpers }
before do
- reportable.coauthorships.first.author.update!(name: "O'Higgins")
+ if reportable.coauthorships.first.author.is_a?(Decidim::Organization)
+ reportable.coauthorships.first.author.update!(name: { en: "O'Higgins" })
+ else
+ reportable.coauthorships.first.author.update!(name: "O'Higgins")
+ end
end
describe "#report" do
diff --git a/decidim-core/spec/mailers/user_report_mailer_spec.rb b/decidim-core/spec/mailers/user_report_mailer_spec.rb
index 1a0a2dd2afa86..2b0d590eb6e82 100644
--- a/decidim-core/spec/mailers/user_report_mailer_spec.rb
+++ b/decidim-core/spec/mailers/user_report_mailer_spec.rb
@@ -4,7 +4,7 @@
module Decidim
describe UserReportMailer do
- let(:organization) { create(:organization, name: "Test Organization") }
+ let(:organization) { create(:organization, name: { en: "Test Organization" }) }
let(:admin) { create(:user, :admin, organization:) }
let(:reporter) { create(:user, :confirmed, organization:) }
let(:moderation) { create(:user_moderation, user:) }
diff --git a/decidim-core/spec/mailers/user_update_mailer_spec.rb b/decidim-core/spec/mailers/user_update_mailer_spec.rb
index 969c83aa593b3..205e589087aa6 100644
--- a/decidim-core/spec/mailers/user_update_mailer_spec.rb
+++ b/decidim-core/spec/mailers/user_update_mailer_spec.rb
@@ -4,7 +4,7 @@
module Decidim
describe UserUpdateMailer do
- let(:organization) { create(:organization, name: "Test Organization") }
+ let(:organization) { create(:organization, name: { ca: "", en: "Test Organization", es: "" }) }
let(:user) { create(:user, :confirmed, organization:) }
let(:updates) { %w(field1 field2 field3) }
diff --git a/decidim-core/spec/models/decidim/organization_spec.rb b/decidim-core/spec/models/decidim/organization_spec.rb
index f5b5c4a30649a..b5d70015c46aa 100644
--- a/decidim-core/spec/models/decidim/organization_spec.rb
+++ b/decidim-core/spec/models/decidim/organization_spec.rb
@@ -56,6 +56,33 @@ module Decidim
subject.default_locale = :en
expect(subject).not_to be_valid
end
+
+ describe "name" do
+ context "when name does not exists" do
+ it "is valid" do
+ expect(described_class.count).to eq(0)
+ expect(subject).to be_valid
+ end
+ end
+
+ context "when name exists for same locale" do
+ let!(:dummy_organization) { create(:organization, name: { en: "Dummy Random 22" }) }
+
+ it "is invalid" do
+ subject.name = { en: "Dummy Random 22" }
+ expect(subject).not_to be_valid
+ end
+ end
+
+ context "when name exists for different locale" do
+ let!(:dummy_organization) { create(:organization, name: { ca: "Dummy Random 22", en: "Dummy" }) }
+
+ it "is invalid" do
+ subject.name = { en: "Dummy Random 22" }
+ expect(subject).not_to be_valid
+ end
+ end
+ end
end
describe "enabled omniauth providers" do
diff --git a/decidim-core/spec/models/decidim/user_spec.rb b/decidim-core/spec/models/decidim/user_spec.rb
index d5106fea277f3..b5f262c9ee02a 100644
--- a/decidim-core/spec/models/decidim/user_spec.rb
+++ b/decidim-core/spec/models/decidim/user_spec.rb
@@ -328,7 +328,7 @@ module Decidim
it "sends the email" do
expect(last_email.to).to eq([user.email])
- expect(last_email.subject).to eq("Thanks for joining #{organization.name}!")
+ expect(last_email.subject).to eq("Thanks for joining #{translated(organization.name)}!")
end
context "when the organization does not send welcome notifications" do
diff --git a/decidim-core/spec/presenters/decidim/organization_presenter_spec.rb b/decidim-core/spec/presenters/decidim/organization_presenter_spec.rb
index f38a3f7bbe829..e49025934bb7d 100644
--- a/decidim-core/spec/presenters/decidim/organization_presenter_spec.rb
+++ b/decidim-core/spec/presenters/decidim/organization_presenter_spec.rb
@@ -5,7 +5,7 @@
module Decidim
describe OrganizationPresenter, type: :helper do
let(:description) { { "en" => " A necessitatibus quo. 1 " } }
- let(:organization) { create(:organization, name: "Organization's name", description:) }
+ let(:organization) { create(:organization, name: { en: "Organization's name" }, description:) }
subject { described_class.new(organization) }
diff --git a/decidim-core/spec/system/accesslist_spec.rb b/decidim-core/spec/system/accesslist_spec.rb
index 20d52e999ff86..d2adeba37e1f8 100644
--- a/decidim-core/spec/system/accesslist_spec.rb
+++ b/decidim-core/spec/system/accesslist_spec.rb
@@ -15,7 +15,7 @@
it "allows access to participants side" do
visit decidim.root_path
- expect(page).to have_content(organization.name)
+ expect(page).to have_content(translated(organization.name))
end
it "allows access to admin side page" do
@@ -32,7 +32,7 @@
it "allows access to participants side" do
visit decidim.root_path
- expect(page).to have_content(organization.name)
+ expect(page).to have_content(translated(organization.name))
end
it "allows access to admin side page" do
diff --git a/decidim-core/spec/system/authentication_spec.rb b/decidim-core/spec/system/authentication_spec.rb
index dbdb3b621f8df..67b5f724ee5f3 100644
--- a/decidim-core/spec/system/authentication_spec.rb
+++ b/decidim-core/spec/system/authentication_spec.rb
@@ -286,10 +286,10 @@
end
within "#notifications" do
- expect(page).to have_content("thanks for joining #{organization.name}")
+ expect(page).to have_content("thanks for joining #{translated(organization.name)}")
end
- expect(last_email_body).to include("thanks for joining #{organization.name}")
+ expect(last_email_body).to include("thanks for joining #{translated(organization.name)}")
end
end
diff --git a/decidim-core/spec/system/homepage_spec.rb b/decidim-core/spec/system/homepage_spec.rb
index 1f2166afd2ce8..d1efee0eae42e 100644
--- a/decidim-core/spec/system/homepage_spec.rb
+++ b/decidim-core/spec/system/homepage_spec.rb
@@ -148,7 +148,7 @@
end
it "welcomes the user" do
- expect(page).to have_content(organization.name)
+ expect(page).to have_content(translated(organization.name))
end
context "when there are static pages" do
@@ -179,7 +179,7 @@
expect(page).to have_css("#footer_sub_hero")
within "#footer_sub_hero" do
- expect(page).to have_content(organization.name)
+ expect(page).to have_content(translated(organization.name))
end
end
@@ -349,7 +349,7 @@
let(:organization) { create(:organization) }
it "does not show the statistics block" do
- expect(page).to have_no_content("Current state of #{organization.name}")
+ expect(page).to have_no_content("Current state of #{translated(organization.name)}")
end
end
@@ -363,7 +363,7 @@
it "shows the statistics block" do
within "#statistics" do
- expect(page).to have_content("Current state of #{organization.name}")
+ expect(page).to have_content("Current state of #{translated(organization.name)}")
expect(page).to have_content("Processes")
expect(page).to have_content("Participants")
end
diff --git a/decidim-core/spec/system/static_pages_spec.rb b/decidim-core/spec/system/static_pages_spec.rb
index 77440b8e44cf0..6f58fbb8d6cab 100644
--- a/decidim-core/spec/system/static_pages_spec.rb
+++ b/decidim-core/spec/system/static_pages_spec.rb
@@ -108,7 +108,7 @@
# ActionDispatch::Cookies::CookieOverflow exception
visit "#{decidim.pages_path}?#{long_parameters}"
- expect(page).to have_content(organization.name)
+ expect(page).to have_content(translated(organization.name))
end
end
diff --git a/decidim-core/spec/types/organization_spec.rb b/decidim-core/spec/types/organization_spec.rb
index ea6a124a9d5b5..c2db84947cec7 100644
--- a/decidim-core/spec/types/organization_spec.rb
+++ b/decidim-core/spec/types/organization_spec.rb
@@ -13,7 +13,7 @@
%(
query {
organization{
- name
+ name { translation(locale: "#{locale}") }
stats{
name
value
@@ -29,7 +29,7 @@
end
it "has name" do
- expect(response["organization"]["name"]).to eq(current_organization.name)
+ expect(response["organization"]["name"]["translation"]).to eq(translated(current_organization.name))
end
%w(
diff --git a/decidim-core/spec/types/organization_type_spec.rb b/decidim-core/spec/types/organization_type_spec.rb
index 8fe65df1b254c..ce682fffff284 100644
--- a/decidim-core/spec/types/organization_type_spec.rb
+++ b/decidim-core/spec/types/organization_type_spec.rb
@@ -15,10 +15,10 @@ module Core
end
describe "name" do
- let(:query) { "{ name }" }
+ let(:query) { %({ name { translation(locale: "en") }}) }
it "returns the organization's name" do
- expect(response).to eq("name" => model.name)
+ expect(response["name"]["translation"]).to eq(translated(model.name))
end
end
diff --git a/decidim-core/spec/types/user_group_type_spec.rb b/decidim-core/spec/types/user_group_type_spec.rb
index 72e2f06ed4217..a54a4f61972d4 100644
--- a/decidim-core/spec/types/user_group_type_spec.rb
+++ b/decidim-core/spec/types/user_group_type_spec.rb
@@ -71,10 +71,10 @@ module Core
end
describe "organizationName" do
- let(:query) { "{ organizationName }" }
+ let(:query) { '{ organizationName { translation(locale: "en") } } ' }
it "returns the group's organization name" do
- expect(response).to include("organizationName" => model.organization.name)
+ expect(response["organizationName"]["translation"]).to eq(translated(model.organization.name))
end
end
diff --git a/decidim-core/spec/types/user_type_spec.rb b/decidim-core/spec/types/user_type_spec.rb
index 60354fde067e1..79613a22a8c27 100644
--- a/decidim-core/spec/types/user_type_spec.rb
+++ b/decidim-core/spec/types/user_type_spec.rb
@@ -87,10 +87,10 @@ module Core
end
describe "organizationName" do
- let(:query) { "{ organizationName }" }
+ let(:query) { '{ organizationName { translation(locale: "en") } } ' }
it "returns the user's organization name" do
- expect(response).to include("organizationName" => model.organization.name)
+ expect(response["organizationName"]["translation"]).to eq(translated(model.organization.name))
end
end
diff --git a/decidim-debates/app/models/decidim/debates/debate.rb b/decidim-debates/app/models/decidim/debates/debate.rb
index 92db7e43f7653..99478aba824c2 100644
--- a/decidim-debates/app/models/decidim/debates/debate.rb
+++ b/decidim-debates/app/models/decidim/debates/debate.rb
@@ -80,7 +80,7 @@ def reported_attributes
# Public: Overrides the `reported_searchable_content_extras` Reportable concern method.
def reported_searchable_content_extras
- [normalized_author.name]
+ [author_name]
end
# Public: Calculates whether the current debate is an AMA-styled one or not.
diff --git a/decidim-initiatives/app/views/decidim/initiatives/initiatives/print.html.erb b/decidim-initiatives/app/views/decidim/initiatives/initiatives/print.html.erb
index d636983fe9d3d..3248134129874 100644
--- a/decidim-initiatives/app/views/decidim/initiatives/initiatives/print.html.erb
+++ b/decidim-initiatives/app/views/decidim/initiatives/initiatives/print.html.erb
@@ -2,10 +2,10 @@
<% if current_organization.logo.present? %>
- <%= image_tag current_organization.attached_uploader(:logo).path(variant: :medium), title: current_organization.name %>
+ <%= image_tag current_organization.attached_uploader(:logo).path(variant: :medium), title: current_organization_name %>
<% end %>
- <%= current_organization.name %>
+ <%= current_organization_name %>
<%= t "section", scope: "decidim.initiatives.initiatives.print" %>
diff --git a/decidim-meetings/app/models/decidim/meetings/meeting.rb b/decidim-meetings/app/models/decidim/meetings/meeting.rb
index eea2f507fa4e1..22001216f0405 100644
--- a/decidim-meetings/app/models/decidim/meetings/meeting.rb
+++ b/decidim-meetings/app/models/decidim/meetings/meeting.rb
@@ -325,7 +325,7 @@ def reported_attributes
# Public: Overrides the `reported_searchable_content_extras` Reportable concern method.
def reported_searchable_content_extras
- [normalized_author.name]
+ [author_name]
end
def has_contributions?
diff --git a/decidim-meetings/app/views/decidim/meetings/admin/invite_join_meeting_mailer/invite.html.erb b/decidim-meetings/app/views/decidim/meetings/admin/invite_join_meeting_mailer/invite.html.erb
index ae49ad0c6a892..7bd4b3bdcec45 100644
--- a/decidim-meetings/app/views/decidim/meetings/admin/invite_join_meeting_mailer/invite.html.erb
+++ b/decidim-meetings/app/views/decidim/meetings/admin/invite_join_meeting_mailer/invite.html.erb
@@ -1,7 +1,9 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @user.name) %>
- <%= t ".invited_you_to_join_a_meeting", invited_by: @invited_by.name, application: @user.organization.name %>
+ <%= t ".invited_you_to_join_a_meeting",
+ invited_by: @invited_by.name,
+ application: translated_attribute(@user.organization.name) %>
diff --git a/decidim-meetings/app/views/decidim/meetings/admin/meetings/_form.html.erb b/decidim-meetings/app/views/decidim/meetings/admin/meetings/_form.html.erb
index 1b3cc89f75f5b..26b5573bd8fe1 100644
--- a/decidim-meetings/app/views/decidim/meetings/admin/meetings/_form.html.erb
+++ b/decidim-meetings/app/views/decidim/meetings/admin/meetings/_form.html.erb
@@ -80,7 +80,7 @@
<%= form.text_field :registration_url, help_text: t(".registration_url_help") %>
- <%= cell("decidim/announcement", t(".disclaimer", organization: current_component.organization.name), callout_class: "alert" ) %>
+ <%= cell("decidim/announcement", t(".disclaimer", organization: organization_name(current_component.organization)), callout_class: "alert" ) %>
diff --git a/decidim-meetings/app/views/decidim/meetings/close_meeting_reminder_mailer/close_meeting_reminder.html.erb b/decidim-meetings/app/views/decidim/meetings/close_meeting_reminder_mailer/close_meeting_reminder.html.erb
index 78a55efd46fbe..1929bdb3b80dc 100644
--- a/decidim-meetings/app/views/decidim/meetings/close_meeting_reminder_mailer/close_meeting_reminder.html.erb
+++ b/decidim-meetings/app/views/decidim/meetings/close_meeting_reminder_mailer/close_meeting_reminder.html.erb
@@ -2,4 +2,4 @@
<%= t("decidim.meetings.close_meeting_reminder_mailer.close_meeting_reminder.body", meeting_title: translated_attribute(@meeting.title), meeting_path: @meeting.reported_content_url).html_safe %>
- <%= t("decidim.meetings.close_meeting_reminder_mailer.close_meeting_reminder.greetings", organization_name: h(@organization.name), organization_url: decidim.root_url(host: @organization.host)).html_safe %>
+ <%= t("decidim.meetings.close_meeting_reminder_mailer.close_meeting_reminder.greetings", organization_name: translated_attribute(@organization.name), organization_url: decidim.root_url(host: @organization.host)).html_safe %>
diff --git a/decidim-meetings/app/views/decidim/meetings/layouts/live_event.html.erb b/decidim-meetings/app/views/decidim/meetings/layouts/live_event.html.erb
index 87d100aa61835..3fdfdd81ef623 100644
--- a/decidim-meetings/app/views/decidim/meetings/layouts/live_event.html.erb
+++ b/decidim-meetings/app/views/decidim/meetings/layouts/live_event.html.erb
@@ -27,7 +27,7 @@
<% end %>
- <%= current_organization.name %> / <%= present(meeting).title(links: true, html_escape: true ) %>
+ <%= current_organization_name %> / <%= present(meeting).title(links: true, html_escape: true ) %>
diff --git a/decidim-meetings/app/views/decidim/meetings/meetings/_form.html.erb b/decidim-meetings/app/views/decidim/meetings/meetings/_form.html.erb
index 4668b9d53cb93..353c3199a9f48 100644
--- a/decidim-meetings/app/views/decidim/meetings/meetings/_form.html.erb
+++ b/decidim-meetings/app/views/decidim/meetings/meetings/_form.html.erb
@@ -80,7 +80,7 @@
<%= form.text_field :registration_url, help_text: t(".registration_url_help") %>
-
+
diff --git a/decidim-meetings/app/views/devise/mailer/join_meeting.html.erb b/decidim-meetings/app/views/devise/mailer/join_meeting.html.erb
index 78a4967549fee..795f1f4ec78ff 100644
--- a/decidim-meetings/app/views/devise/mailer/join_meeting.html.erb
+++ b/decidim-meetings/app/views/devise/mailer/join_meeting.html.erb
@@ -1,7 +1,9 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.name) %>
- <%= t("decidim.meetings.admin.invite_join_meeting_mailer.invite.invited_you_to_join_a_meeting", invited_by: @resource.invited_by.name, application: @resource.organization.name) %>
+ <%= t("decidim.meetings.admin.invite_join_meeting_mailer.invite.invited_you_to_join_a_meeting",
+ invited_by: @resource.invited_by.name,
+ application: translated_attribute(@resource.organization.name)) %>
<%= link_to t("devise.mailer.invitation_instructions.decline"), accept_invitation_url(@resource, invitation_token: @token, invite_redirect: Decidim::EngineRouter.main_proxy(@opts[:meeting].component).decline_invitation_meeting_registration_path(meeting_id: @opts[:meeting], participatory_space_id: @opts[:meeting].component.participatory_space), host: @resource.organization.host) %>
diff --git a/decidim-meetings/app/views/devise/mailer/join_meeting.text.erb b/decidim-meetings/app/views/devise/mailer/join_meeting.text.erb
index 541ba5126a0bd..94fc66f3a388e 100644
--- a/decidim-meetings/app/views/devise/mailer/join_meeting.text.erb
+++ b/decidim-meetings/app/views/devise/mailer/join_meeting.text.erb
@@ -1,6 +1,8 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.name) %>
-<%= t("decidim.meetings.admin.invite_join_meeting_mailer.invite.invited_you_to_join_a_meeting", invited_by: @resource.invited_by.name, application: @resource.organization.name) %>
+<%= t("decidim.meetings.admin.invite_join_meeting_mailer.invite.invited_you_to_join_a_meeting",
+ invited_by: @resource.invited_by.name,
+ application: translated_attribute(@resource.organization.name)) %>
<%= t("devise.mailer.invitation_instructions.decline") %>:
<% accept_invitation_url(@resource, invitation_token: @token, invite_redirect: Decidim::EngineRouter.main_proxy(@opts[:meeting].component).decline_invitation_meeting_registration_path(meeting_id: @opts[:meeting], participatory_space_id: @opts[:meeting].component.participatory_space), host: @resource.organization.host) %>
diff --git a/decidim-participatory_processes/spec/system/participatory_processes_spec.rb b/decidim-participatory_processes/spec/system/participatory_processes_spec.rb
index 9685d6f6ec776..15dc2d9879903 100644
--- a/decidim-participatory_processes/spec/system/participatory_processes_spec.rb
+++ b/decidim-participatory_processes/spec/system/participatory_processes_spec.rb
@@ -220,7 +220,7 @@
it "has the participatory process title in the show page" do
visit decidim_participatory_processes.participatory_process_path(participatory_process)
- expect(page).to have_title("#{translated(participatory_process.title)} - #{organization.name}")
+ expect(page).to have_title("#{translated(participatory_process.title)} - #{translated(organization.name)}")
end
end
diff --git a/decidim-proposals/lib/decidim/api/proposal_type.rb b/decidim-proposals/lib/decidim/api/proposal_type.rb
index 89b7c42e1358d..ef84dc1a261f6 100644
--- a/decidim-proposals/lib/decidim/api/proposal_type.rb
+++ b/decidim-proposals/lib/decidim/api/proposal_type.rb
@@ -26,6 +26,7 @@ class ProposalType < Decidim::Api::Types::BaseObject
def coordinates
[object.latitude, object.longitude]
end
+
field :reference, GraphQL::Types::String, "This proposal's unique reference", null: true
field :state, GraphQL::Types::String, "The answer status in which proposal is in", null: true
field :answer, Decidim::Core::TranslatedFieldType, "The answer feedback for the status for this proposal", null: true
diff --git a/decidim-proposals/spec/types/integration_schema_spec.rb b/decidim-proposals/spec/types/integration_schema_spec.rb
index 3e08c4ba2ece0..18393a7a2a752 100644
--- a/decidim-proposals/spec/types/integration_schema_spec.rb
+++ b/decidim-proposals/spec/types/integration_schema_spec.rb
@@ -46,7 +46,7 @@
"id" => e.author.id.to_s,
"name" => e.author.name,
"nickname" => "@#{e.author.nickname}",
- "organizationName" => e.author.organization.name,
+ "organizationName" => { "translation" => translated(e.author.organization.name) },
"profilePath" => "/profiles/#{e.author.nickname}" }
end,
"endorsementsCount" => proposal.endorsements.size,
@@ -144,7 +144,7 @@
deleted
name
nickname
- organizationName
+ organizationName { translation(locale: "en") }
profilePath
}
endorsementsCount
@@ -249,7 +249,7 @@
deleted
name
nickname
- organizationName
+ organizationName { translation(locale: "en") }
profilePath
}
endorsementsCount
diff --git a/decidim-system/app/commands/decidim/system/populate_help.rb b/decidim-system/app/commands/decidim/system/populate_help.rb
index 12d2a931e7c89..6d4473e22ed03 100644
--- a/decidim-system/app/commands/decidim/system/populate_help.rb
+++ b/decidim-system/app/commands/decidim/system/populate_help.rb
@@ -4,6 +4,8 @@ module Decidim
module System
# A command that will create default help pages for an organization.
class PopulateHelp < Decidim::Command
+ include Decidim::TranslatableAttributes
+
# Public: Initializes the command.
#
# organization - An organization
@@ -17,8 +19,8 @@ def initialize(organization)
def call
ActiveRecord::Base.transaction do
topic = Decidim::StaticPageTopic.create!(
- title: multi_translation("decidim.help.main_topic.title", organization: @organization.name),
- description: multi_translation("decidim.help.main_topic.description", organization: @organization.name),
+ title: multi_translation("decidim.help.main_topic.title", organization: organization_name),
+ description: multi_translation("decidim.help.main_topic.description", organization: organization_name),
organization: @organization,
show_in_footer: true,
weight: 0
@@ -26,8 +28,8 @@ def call
Decidim::StaticPage.create!(
slug: "help",
- title: multi_translation("decidim.help.main_topic.default_page.title", organization: @organization.name),
- content: multi_translation("decidim.help.main_topic.default_page.content", organization: @organization.name),
+ title: multi_translation("decidim.help.main_topic.default_page.title", organization: organization_name),
+ content: multi_translation("decidim.help.main_topic.default_page.content", organization: organization_name),
topic:,
organization: @organization,
weight: 0
@@ -53,6 +55,10 @@ def call
def multi_translation(key, **)
Decidim::TranslationsHelper.multi_translation(key, @organization.available_locales, **)
end
+
+ def organization_name
+ translated_attribute(@organization.name)
+ end
end
end
end
diff --git a/decidim-system/app/commands/decidim/system/register_organization.rb b/decidim-system/app/commands/decidim/system/register_organization.rb
index 0621309436ba6..82daac9d90543 100644
--- a/decidim-system/app/commands/decidim/system/register_organization.rb
+++ b/decidim-system/app/commands/decidim/system/register_organization.rb
@@ -49,7 +49,7 @@ def call
def create_organization
Decidim::Organization.create!(
- name: form.name,
+ name: { form.default_locale => form.name },
host: form.host,
secondary_hosts: form.clean_secondary_hosts,
reference_prefix: form.reference_prefix,
diff --git a/decidim-system/app/controllers/decidim/system/organizations_controller.rb b/decidim-system/app/controllers/decidim/system/organizations_controller.rb
index 7c98a238b0664..183d5dac8bbdb 100644
--- a/decidim-system/app/controllers/decidim/system/organizations_controller.rb
+++ b/decidim-system/app/controllers/decidim/system/organizations_controller.rb
@@ -39,6 +39,7 @@ def edit
end
def update
+ @organization = Organization.find(params[:id])
@form = form(UpdateOrganizationForm).from_params(params)
UpdateOrganization.call(params[:id], @form) do
diff --git a/decidim-system/app/forms/decidim/system/base_organization_form.rb b/decidim-system/app/forms/decidim/system/base_organization_form.rb
new file mode 100644
index 0000000000000..34c71ea4cab24
--- /dev/null
+++ b/decidim-system/app/forms/decidim/system/base_organization_form.rb
@@ -0,0 +1,123 @@
+# frozen_string_literal: true
+
+require "decidim/translatable_attributes"
+
+module Decidim
+ module System
+ # A form object to be inherited to create and update organizations from the system dashboard.
+ #
+ class BaseOrganizationForm < Form
+ include TranslatableAttributes
+ include JsonbAttributes
+
+ mimic :organization
+
+ attribute :host, String
+ attribute :secondary_hosts, String
+ attribute :force_users_to_authenticate_before_access_organization, Boolean
+ attribute :available_authorizations, Array[String]
+ attribute :users_registration_mode, String
+ attribute :default_locale, String
+
+ jsonb_attribute :smtp_settings, [
+ [:from, String],
+ [:from_email, String],
+ [:from_label, String],
+ [:user_name, String],
+ [:encrypted_password, String],
+ [:address, String],
+ [:port, Integer],
+ [:authentication, String],
+ [:enable_starttls_auto, Boolean]
+ ]
+
+ jsonb_attribute :content_security_policy, [
+ [:"default-src", String],
+ [:"img-src", String],
+ [:"media-src", String],
+ [:"script-src", String],
+ [:"style-src", String],
+ [:"frame-src", String],
+ [:"font-src", String],
+ [:"connect-src", String]
+ ]
+
+ attribute :password, String
+ attribute :file_upload_settings, FileUploadSettingsForm
+
+ OMNIATH_PROVIDERS_ATTRIBUTES = Decidim::OmniauthProvider.available.keys.map do |provider|
+ Rails.application.secrets.dig(:omniauth, provider).keys.map do |setting|
+ if setting == :enabled
+ ["omniauth_settings_#{provider}_enabled".to_sym, Boolean]
+ else
+ ["omniauth_settings_#{provider}_#{setting}".to_sym, String]
+ end
+ end
+ end.flatten(1)
+
+ jsonb_attribute :omniauth_settings, OMNIATH_PROVIDERS_ATTRIBUTES
+
+ validates :host, :users_registration_mode, presence: true
+ validate :validate_organization_uniqueness
+ validate :validate_secret_key_base_for_encryption
+ validates :users_registration_mode, inclusion: { in: Decidim::Organization.users_registration_modes }
+
+ def map_model(model)
+ self.default_locale = model.default_locale
+ self.secondary_hosts = model.secondary_hosts.join("\n")
+ self.omniauth_settings = (model.omniauth_settings || {}).transform_values do |v|
+ Decidim::OmniauthProvider.value_defined?(v) ? Decidim::AttributeEncryptor.decrypt(v) : v
+ end
+ self.file_upload_settings = FileUploadSettingsForm.from_model(model.file_upload_settings)
+ end
+
+ def clean_secondary_hosts
+ return unless secondary_hosts
+
+ secondary_hosts.split("\n").map(&:chomp).select(&:present?)
+ end
+
+ def clean_available_authorizations
+ return unless available_authorizations
+
+ available_authorizations.select(&:present?)
+ end
+
+ def password
+ encrypted_password.nil? ? super : Decidim::AttributeEncryptor.decrypt(encrypted_password)
+ end
+
+ def encrypted_smtp_settings
+ smtp_settings["from"] = set_from
+
+ smtp_settings.merge(encrypted_password: Decidim::AttributeEncryptor.encrypt(password))
+ end
+
+ def set_from
+ return from_email if from_label.blank?
+
+ "#{from_label} <#{from_email}>"
+ end
+
+ def encrypted_omniauth_settings
+ omniauth_settings.transform_values do |v|
+ Decidim::OmniauthProvider.value_defined?(v) ? Decidim::AttributeEncryptor.encrypt(v) : v
+ end
+ end
+
+ private
+
+ # We need a valid secret key base for encrypting the SMTP password with it
+ # It is also necessary for other things in Rails (like Cookies encryption)
+ def validate_secret_key_base_for_encryption
+ return if Rails.application.secrets.secret_key_base&.length == 128
+
+ errors.add(:password, I18n.t("activemodel.errors.models.organization.attributes.password.secret_key"))
+ end
+
+ def validate_organization_uniqueness
+ raise "#{self.class.name} is expected to implement #validate_organization_uniqueness"
+ end
+ end
+ end
+end
diff --git a/decidim-system/app/forms/decidim/system/register_organization_form.rb b/decidim-system/app/forms/decidim/system/register_organization_form.rb
index 5f36993ed7eee..169a34db7ad8f 100644
--- a/decidim-system/app/forms/decidim/system/register_organization_form.rb
+++ b/decidim-system/app/forms/decidim/system/register_organization_form.rb
@@ -6,10 +6,12 @@ module Decidim
module System
# A form object used to create organizations from the system dashboard.
#
- class RegisterOrganizationForm < UpdateOrganizationForm
+ class RegisterOrganizationForm < BaseOrganizationForm
include JsonbAttributes
mimic :organization
+ attribute :name, String
+
attribute :organization_admin_email, String
attribute :organization_admin_name, String
attribute :available_locales, Array
@@ -18,11 +20,29 @@ class RegisterOrganizationForm < UpdateOrganizationForm
attribute :users_registration_mode, String
attribute :force_users_to_authenticate_before_access_organization, Boolean
- validates :organization_admin_email, :organization_admin_name, :name, :host, :reference_prefix, :users_registration_mode, presence: true
+ validates :organization_admin_email, :organization_admin_name, :name, :reference_prefix, presence: true
+ validates :name, presence: true
validates :available_locales, presence: true
validates :default_locale, presence: true
validates :default_locale, inclusion: { in: :available_locales }
- validates :users_registration_mode, inclusion: { in: Decidim::Organization.users_registration_modes }
+
+ private
+
+ def validate_organization_uniqueness
+ base_query = Decidim::Organization.pluck(:name)
+
+ organization_names = []
+
+ base_query.each do |value|
+ organization_names += value.except("machine_translations").values
+ organization_names += value.fetch("machine_translations", {}).values
+ end
+
+ organization_names = organization_names.map(&:downcase)
+
+ errors.add(:name, :taken) if organization_names.include?(name&.downcase)
+ errors.add(:host, :taken) if Decidim::Organization.where(host:).where.not(id:).exists?
+ end
end
end
end
diff --git a/decidim-system/app/forms/decidim/system/update_organization_form.rb b/decidim-system/app/forms/decidim/system/update_organization_form.rb
index 710a3472f5ab7..437a86fdb6d12 100644
--- a/decidim-system/app/forms/decidim/system/update_organization_form.rb
+++ b/decidim-system/app/forms/decidim/system/update_organization_form.rb
@@ -6,117 +6,38 @@ module Decidim
module System
# A form object used to update organizations from the system dashboard.
#
- class UpdateOrganizationForm < Form
- include TranslatableAttributes
- include JsonbAttributes
+ class UpdateOrganizationForm < BaseOrganizationForm
+ translatable_attribute :name, String
- mimic :organization
+ validate :validate_organization_name_presence
- attribute :name, String
- attribute :host, String
- attribute :secondary_hosts, String
- attribute :force_users_to_authenticate_before_access_organization, Boolean
- attribute :available_authorizations, Array[String]
- attribute :users_registration_mode, String
- jsonb_attribute :smtp_settings, [
- [:from, String],
- [:from_email, String],
- [:from_label, String],
- [:user_name, String],
- [:encrypted_password, String],
- [:address, String],
- [:port, Integer],
- [:authentication, String],
- [:enable_starttls_auto, Boolean]
- ]
-
- jsonb_attribute :content_security_policy, [
- [:"default-src", String],
- [:"img-src", String],
- [:"media-src", String],
- [:"script-src", String],
- [:"style-src", String],
- [:"frame-src", String],
- [:"font-src", String],
- [:"connect-src", String]
- ]
-
- attribute :password, String
- attribute :file_upload_settings, FileUploadSettingsForm
-
- OMNIATH_PROVIDERS_ATTRIBUTES = Decidim::OmniauthProvider.available.keys.map do |provider|
- Rails.application.secrets.dig(:omniauth, provider).keys.map do |setting|
- if setting == :enabled
- ["omniauth_settings_#{provider}_enabled".to_sym, Boolean]
- else
- ["omniauth_settings_#{provider}_#{setting}".to_sym, String]
- end
- end
- end.flatten(1)
-
- jsonb_attribute :omniauth_settings, OMNIATH_PROVIDERS_ATTRIBUTES
-
- validates :name, :host, :users_registration_mode, presence: true
- validate :validate_organization_uniqueness
- validate :validate_secret_key_base_for_encryption
- validates :users_registration_mode, inclusion: { in: Decidim::Organization.users_registration_modes }
-
- def map_model(model)
- self.secondary_hosts = model.secondary_hosts.join("\n")
- self.omniauth_settings = (model.omniauth_settings || {}).transform_values do |v|
- Decidim::OmniauthProvider.value_defined?(v) ? Decidim::AttributeEncryptor.decrypt(v) : v
- end
- self.file_upload_settings = FileUploadSettingsForm.from_model(model.file_upload_settings)
- end
-
- def clean_secondary_hosts
- return unless secondary_hosts
-
- secondary_hosts.split("\n").map(&:chomp).select(&:present?)
- end
-
- def clean_available_authorizations
- return unless available_authorizations
+ private
- available_authorizations.select(&:present?)
+ def validate_organization_name_presence
+ translated_attr = "name_#{current_organization.try(:default_locale) || Decidim.default_locale.to_s}".to_sym
+ errors.add(translated_attr, :blank) if send(translated_attr).blank?
end
- def password
- encrypted_password.nil? ? super : Decidim::AttributeEncryptor.decrypt(encrypted_password)
- end
+ def validate_organization_uniqueness
+ base_query = persisted? ? Decidim::Organization.where.not(id:).all : Decidim::Organization.all
- def encrypted_smtp_settings
- smtp_settings["from"] = set_from
+ organization_names = []
- smtp_settings.merge(encrypted_password: Decidim::AttributeEncryptor.encrypt(password))
- end
+ base_query.pluck(:name).each do |value|
+ organization_names += value.except("machine_translations").values
+ organization_names += value.fetch("machine_translations", {}).values
+ end
- def set_from
- return from_email if from_label.blank?
+ organization_names = organization_names.map(&:downcase).compact_blank
- "#{from_label} <#{from_email}>"
- end
+ name.each do |language, value|
+ next if value.is_a?(Hash)
- def encrypted_omniauth_settings
- omniauth_settings.transform_values do |v|
- Decidim::OmniauthProvider.value_defined?(v) ? Decidim::AttributeEncryptor.encrypt(v) : v
+ errors.add("name_#{language}", :taken) if organization_names.include?(value.downcase)
end
- end
- private
-
- def validate_organization_uniqueness
- errors.add(:name, :taken) if Decidim::Organization.where(name:).where.not(id:).exists?
errors.add(:host, :taken) if Decidim::Organization.where(host:).where.not(id:).exists?
end
-
- # We need a valid secret key base for encrypting the SMTP password with it
- # It is also necessary for other things in Rails (like Cookies encryption)
- def validate_secret_key_base_for_encryption
- return if Rails.application.secrets.secret_key_base&.length == 128
-
- errors.add(:password, I18n.t("activemodel.errors.models.organization.attributes.password.secret_key"))
- end
end
end
end
diff --git a/decidim-system/app/packs/stylesheets/decidim/system/application.scss b/decidim-system/app/packs/stylesheets/decidim/system/application.scss
index ef45f4c4e1e1e..d7f93399f2bd0 100644
--- a/decidim-system/app/packs/stylesheets/decidim/system/application.scss
+++ b/decidim-system/app/packs/stylesheets/decidim/system/application.scss
@@ -107,3 +107,60 @@ dl {
.ts-dropdown {
margin: 0;
}
+
+.tabs--lang {
+ @apply bg-transparent flex items-center gap-x-1;
+
+ li {
+ @apply p-0.5 rounded-t-sm text-secondary text-xs;
+
+ background-color: rgba(243, 244, 247, 1);
+
+ &.is-active,
+ &:hover {
+ @apply border-b border-secondary;
+ }
+
+ &:hover {
+ background-color: rgba(243, 244, 247, 1);
+ }
+ }
+
+ a {
+ @apply text-xs p-0;
+
+ &::before {
+ @apply content-[''] w-2 h-2 inline-block bg-white rounded-full mr-2 border;
+
+ border-color: rgba(116, 129, 144, 1);
+ }
+ }
+
+ .tabs-title > a[aria-selected="true"] {
+ @apply font-bold text-secondary;
+
+ background-color: rgba(243, 244, 247, 1);
+
+ &::before {
+ @apply border-white;
+
+ background-color: rgba(40, 167, 69, 1);
+ }
+ }
+
+ a.is-tab-error {
+ color: red;
+ }
+}
+
+.label--tabs {
+ @apply flex justify-between items-end;
+
+ label {
+ @apply inline-block;
+ }
+}
+
+.tabs-panel[aria-hidden="true"] {
+ @apply hidden;
+}
diff --git a/decidim-system/app/views/decidim/system/oauth_applications/_form.html.erb b/decidim-system/app/views/decidim/system/oauth_applications/_form.html.erb
index ca5e2d4767a65..531da09567a24 100644
--- a/decidim-system/app/views/decidim/system/oauth_applications/_form.html.erb
+++ b/decidim-system/app/views/decidim/system/oauth_applications/_form.html.erb
@@ -2,7 +2,7 @@
<%= form.text_field :name %>
<%= form.text_field :redirect_uri %>
<%= form.select :decidim_organization_id,
- Decidim::Organization.pluck(:name, :id),
+ Decidim::Organization.all.map { |o| [organization_name(o), o.id] },
{ include_blank: t(".select_organization") },
{ multiple: false } %>
<%= form.text_field :organization_name %>
diff --git a/decidim-system/app/views/decidim/system/organizations/edit.html.erb b/decidim-system/app/views/decidim/system/organizations/edit.html.erb
index 01c5f92efebd0..db75497023d4c 100644
--- a/decidim-system/app/views/decidim/system/organizations/edit.html.erb
+++ b/decidim-system/app/views/decidim/system/organizations/edit.html.erb
@@ -4,9 +4,11 @@
<%= t ".title" %>
<% end %>
-<%= decidim_form_for(@form) do |f| %>
+<%= decidim_form_for(@form, url: organization_path(@organization)) do |f| %>
- <%= f.text_field :name, autofocus: true %>
+
+ <%= f.translated :text_field, :name, autofocus: true %>
+
<%= f.text_field :host %>
diff --git a/decidim-system/app/views/decidim/system/shared/_organizations_list.html.erb b/decidim-system/app/views/decidim/system/shared/_organizations_list.html.erb
index a0e63a7d0fc20..1330fe389dc32 100644
--- a/decidim-system/app/views/decidim/system/shared/_organizations_list.html.erb
+++ b/decidim-system/app/views/decidim/system/shared/_organizations_list.html.erb
@@ -10,7 +10,7 @@
<% organizations.each do |organization| %>
- <%= link_to organization.name, edit_organization_path(organization) %>
+ <%= link_to organization_name(organization), edit_organization_path(organization) %>
<%= organization.host %>
|
diff --git a/decidim-system/spec/commands/decidim/system/register_organization_spec.rb b/decidim-system/spec/commands/decidim/system/register_organization_spec.rb
index 3801904b90ac6..b8fdc2a90fb48 100644
--- a/decidim-system/spec/commands/decidim/system/register_organization_spec.rb
+++ b/decidim-system/spec/commands/decidim/system/register_organization_spec.rb
@@ -51,8 +51,7 @@ module System
it "creates a new organization" do
expect { command.call }.to change(Organization, :count).by(1)
organization = Organization.last
-
- expect(organization.name).to eq("Gotham City")
+ expect(translated(organization.name)).to eq("Gotham City")
expect(organization.host).to eq("decide.example.org")
expect(organization.secondary_hosts).to contain_exactly("foo.example.org", "bar.example.org")
expect(organization.external_domain_allowlist).to contain_exactly("decidim.org", "github.com")
@@ -73,7 +72,7 @@ module System
admin = User.last
expect(admin.email).to eq("f.laguardia@example.org")
- expect(admin.organization.name).to eq("Gotham City")
+ expect(translated(admin.organization.name)).to eq("Gotham City")
expect(admin).to be_admin
expect(admin).to be_created_by_invite
expect(admin).to be_valid
diff --git a/decidim-system/spec/commands/decidim/system/update_organization_spec.rb b/decidim-system/spec/commands/decidim/system/update_organization_spec.rb
index 52a63f1920a78..9bd7b89a8f463 100644
--- a/decidim-system/spec/commands/decidim/system/update_organization_spec.rb
+++ b/decidim-system/spec/commands/decidim/system/update_organization_spec.rb
@@ -9,7 +9,7 @@ module System
let(:form) do
UpdateOrganizationForm.new(params)
end
- let(:organization) { create(:organization, name: "My organization") }
+ let(:organization) { create(:organization, name: { en: "My organization" }) }
let(:command) { described_class.new(organization.id, form) }
@@ -17,7 +17,7 @@ module System
let(:from_label) { "Decide Gotham" }
let(:params) do
{
- name: "Gotham City",
+ name: { en: "Gotham City" },
host: "decide.example.org",
secondary_hosts: "foo.example.org\r\n\r\nbar.example.org",
force_users_to_authenticate_before_access_organization: false,
@@ -48,7 +48,7 @@ module System
expect { command.call }.to change(Organization, :count).by(1)
organization = Organization.last
- expect(organization.name).to eq("Gotham City")
+ expect(translated(organization.name)).to eq("Gotham City")
expect(organization.host).to eq("decide.example.org")
expect(organization.secondary_hosts).to contain_exactly("foo.example.org", "bar.example.org")
expect(organization.users_registration_mode).to eq("existing")
@@ -80,15 +80,43 @@ module System
end
context "when the form is invalid" do
- let(:params) do
- {
- name: nil,
- host: "foo.com"
- }
+ context "and the name is empty" do
+ let(:params) do
+ {
+ name: { en: "" },
+ host: "foo.com"
+ }
+ end
+
+ it "returns an invalid response" do
+ expect { command.call }.to broadcast(:invalid)
+ end
+ end
+
+ context "and the name is empty hash" do
+ let(:params) do
+ {
+ name: {},
+ host: "foo.com"
+ }
+ end
+
+ it "returns an invalid response" do
+ expect { command.call }.to broadcast(:invalid)
+ end
end
- it "returns an invalid response" do
- expect { command.call }.to broadcast(:invalid)
+ context "and the name is nil" do
+ let(:params) do
+ {
+ name: nil,
+ host: "foo.com"
+ }
+ end
+
+ it "returns an invalid response" do
+ expect { command.call }.to broadcast(:invalid)
+ end
end
end
diff --git a/decidim-system/spec/forms/decidim/system/update_organization_form_spec.rb b/decidim-system/spec/forms/decidim/system/update_organization_form_spec.rb
index b28030cd4c75b..d146682294d9f 100644
--- a/decidim-system/spec/forms/decidim/system/update_organization_form_spec.rb
+++ b/decidim-system/spec/forms/decidim/system/update_organization_form_spec.rb
@@ -6,7 +6,7 @@ module Decidim::System
describe UpdateOrganizationForm do
subject do
described_class.new(
- name: "Gotham City",
+ name: { ca: "", en: "Gotham City", es: "" },
host: "decide.example.org",
secondary_hosts: "foo.example.org\r\n\r\nbar.example.org",
reference_prefix: "JKR",
diff --git a/decidim-system/spec/system/dashboard_spec.rb b/decidim-system/spec/system/dashboard_spec.rb
index 520e599ac6317..a6863de3b96f5 100644
--- a/decidim-system/spec/system/dashboard_spec.rb
+++ b/decidim-system/spec/system/dashboard_spec.rb
@@ -4,7 +4,7 @@
describe "Organizations" do
let(:admin) { create(:admin, email: "system@example.org") }
- let(:organization) { create(:organization, name: "Citizen Corp") }
+ let(:organization) { create(:organization, name: { ca: "", en: "Citizen Corp", es: "" }) }
context "when an admin authenticated" do
before do
diff --git a/decidim-system/spec/system/manage_oauth_applications_spec.rb b/decidim-system/spec/system/manage_oauth_applications_spec.rb
index 95c9a8fa55f75..1586832456517 100644
--- a/decidim-system/spec/system/manage_oauth_applications_spec.rb
+++ b/decidim-system/spec/system/manage_oauth_applications_spec.rb
@@ -19,7 +19,7 @@
within ".new_oauth_application" do
fill_in :oauth_application_name, with: "Meta Decidim"
fill_in :oauth_application_redirect_uri, with: "https://example.org/oauth/decidim"
- select organization.name, from: :oauth_application_decidim_organization_id
+ select translated(organization.name), from: :oauth_application_decidim_organization_id
fill_in :oauth_application_organization_name, with: "Ajuntament de Barcelona"
fill_in :oauth_application_organization_url, with: "https://www.barcelona.cat"
end
diff --git a/decidim-system/spec/system/organizations_spec.rb b/decidim-system/spec/system/organizations_spec.rb
index fe4dd00b1c3a2..c5fab3b1463e8 100644
--- a/decidim-system/spec/system/organizations_spec.rb
+++ b/decidim-system/spec/system/organizations_spec.rb
@@ -126,7 +126,7 @@
end
describe "editing an organization" do
- let!(:organization) { create(:organization, name: "Citizen Corp") }
+ let!(:organization) { create(:organization, name: { ca: "", en: "Citizen Corp", es: "" }) }
before do
click_on "Organizations"
@@ -137,17 +137,33 @@
it_behaves_like "form hiding advanced settings"
+ it "properly validate name" do
+ create(:organization, name: { ca: "", en: "Duplicate organization", es: "" })
+
+ fill_in_i18n :update_organization_name, "#update_organization-name-tabs", en: "Citizens Rule!", ca: "Something", es: "Another"
+ click_on "Save"
+
+ within "table tbody tr", text: "Citizens Rule!" do
+ click_on "Edit"
+ end
+ fill_in_i18n :update_organization_name, "#update_organization-name-tabs", en: "Citizens Rule!", ca: "", es: ""
+ click_on "Save"
+
+ expect(page).to have_css("div.flash.success")
+ expect(page).to have_content("Citizens Rule!")
+ end
+
it "edits the data" do
- fill_in "Name", with: "Citizens Rule!"
+ fill_in_i18n :update_organization_name, "#update_organization-name-tabs", en: "Citizens Rule!"
fill_in "Host", with: "www.example.org"
fill_in "Secondary hosts", with: "foobar.example.org\n\rbar.example.org"
choose "Do not allow participants to register, but allow existing participants to login"
check "Example authorization (Direct)"
click_on "Show advanced settings"
- check "organization_omniauth_settings_facebook_enabled"
- fill_in "organization_omniauth_settings_facebook_app_id", with: "facebook-app-id"
- fill_in "organization_omniauth_settings_facebook_app_secret", with: "facebook-app-secret"
+ check "update_organization_omniauth_settings_facebook_enabled"
+ fill_in "update_organization_omniauth_settings_facebook_app_id", with: "facebook-app-id"
+ fill_in "update_organization_omniauth_settings_facebook_app_secret", with: "facebook-app-secret"
click_on "Save"
@@ -161,7 +177,7 @@
end
it "shows the error message" do
- fill_in "Name", with: "Citizens Rule!"
+ fill_in_i18n :update_organization_name, "#update_organization-name-tabs", en: "Citizens Rule!"
fill_in "Host", with: "www.example.org"
click_on "Save"
@@ -173,7 +189,7 @@
describe "editing an organization with disabled OmniAuth provider" do
let!(:organization) do
- create(:organization, name: "Citizen Corp", default_locale: :es, available_locales: ["es"], description: { es: "Un texto largo" })
+ create(:organization, name: { ca: "", en: "Citizen Corp", es: "" }, default_locale: :es, available_locales: ["es"], description: { es: "Un texto largo" })
end
before do
@@ -205,7 +221,9 @@
)
# Reload the UpdateOrganizationForm
+ Decidim::System.send(:remove_const, :BaseOrganizationForm)
Decidim::System.send(:remove_const, :UpdateOrganizationForm)
+ load "#{Decidim::System::Engine.root}/app/forms/decidim/system/base_organization_form.rb"
load "#{Decidim::System::Engine.root}/app/forms/decidim/system/update_organization_form.rb"
click_on "Organizations"
@@ -218,7 +236,9 @@
after do
# Reload the UpdateOrganizationForm
+ Decidim::System.send(:remove_const, :BaseOrganizationForm)
Decidim::System.send(:remove_const, :UpdateOrganizationForm)
+ load "#{Decidim::System::Engine.root}/app/forms/decidim/system/base_organization_form.rb"
load "#{Decidim::System::Engine.root}/app/forms/decidim/system/update_organization_form.rb"
end
diff --git a/decidim-templates/app/controllers/decidim/templates/admin/proposal_answer_templates_controller.rb b/decidim-templates/app/controllers/decidim/templates/admin/proposal_answer_templates_controller.rb
index 4164a7f5a6822..dab5deae04c4f 100644
--- a/decidim-templates/app/controllers/decidim/templates/admin/proposal_answer_templates_controller.rb
+++ b/decidim-templates/app/controllers/decidim/templates/admin/proposal_answer_templates_controller.rb
@@ -140,7 +140,7 @@ def available_states(component_id = nil)
def populate_template_interpolations(proposal)
template.description.to_h do |language, value|
- value.gsub!("%{organization}", proposal.organization.name)
+ value.gsub!("%{organization}", translated_attribute(proposal.organization.name))
value.gsub!("%{name}", author_name(proposal))
value.gsub!("%{admin}", current_user.name)
diff --git a/decidim-templates/spec/system/admin/admin_manages_proposal_answer_templates_spec.rb b/decidim-templates/spec/system/admin/admin_manages_proposal_answer_templates_spec.rb
index f10027341afa6..2fd1c6faa22bf 100644
--- a/decidim-templates/spec/system/admin/admin_manages_proposal_answer_templates_spec.rb
+++ b/decidim-templates/spec/system/admin/admin_manages_proposal_answer_templates_spec.rb
@@ -226,7 +226,7 @@
it "changes it with the organization name" do
within ".edit_proposal_answer" do
select template.name["en"], from: :proposal_answer_template_chooser
- expect(page).to have_content("Some meaningful answer with the #{organization.name}")
+ expect(page).to have_content("Some meaningful answer with the #{translated(organization.name)}")
end
end
end
| |