Merge pull request #11487 from pedrocarmona/feature/invitation-email-locale

Send translated email when creating users via super admin interface
This commit is contained in:
Konrad
2023-09-07 16:41:59 +02:00
committed by GitHub
8 changed files with 64 additions and 19 deletions

View File

@@ -3,6 +3,8 @@
module Spree
module Admin
class UsersController < ::Admin::ResourceController
helper I18nHelper
rescue_from Spree::User::DestroyWithOrdersError, with: :user_destroy_with_orders_error
after_action :sign_in_if_change_own_password, only: :update
@@ -127,6 +129,10 @@ module Spree
params[:user][:email] != @user.email
end
def build_resource
model_class.new(locale: I18n.default_locale)
end
def user_params
::PermittedAttributes::User.new(params).call(
%i[enterprise_limit show_api_key_view]

View File

@@ -1,6 +1,12 @@
# frozen_string_literal: true
module I18nHelper
def locale_options
OpenFoodNetwork::I18nConfig.available_locales.map do |locale|
[t('language_name', locale:), locale]
end
end
def set_locale
UserLocaleSetter.new(spree_current_user, params[:locale], cookies).set_locale
end

View File

@@ -16,7 +16,7 @@ module PermittedAttributes
def permitted_attributes
[
:email, :password, :password_confirmation, :disabled,
:email, :locale, :password, :password_confirmation, :disabled,
{ webhook_endpoints_attributes: [:id, :url] },
]
end

View File

@@ -12,6 +12,9 @@
= check_box_tag "user[spree_role_ids][]", role.id, @user.spree_roles.include?(role), id: "user_spree_role_#{role.name}"
= label_tag role.name
= hidden_field_tag "user[spree_role_ids][]", ""
= f.field_container :locale do
= f.label :locale, t(".locale")
= f.select :locale, locale_options, class: "fullwidth"
= f.field_container :enterprise_limit do
= f.label :enterprise_limit, t(".enterprise_limit")
= f.text_field :enterprise_limit, class: "fullwidth"