diff --git a/Gemfile b/Gemfile index a1eae116bce4500a9144a9e65503c69cb76cdff1..a0135feea07d9e3d46e6419204c6c48eccbe4860 100644 --- a/Gemfile +++ b/Gemfile @@ -34,6 +34,7 @@ gem "hal_openscience", "~> 0.1" # gem "hal_openscience", path: "../hal_openscience" gem "has_scope", "~> 0.8.0" gem "hash_dot" +gem "i18n_data", "~> 0.17.1" gem "image_processing" gem "jbuilder" gem "jquery-rails" @@ -90,3 +91,4 @@ group :test do end gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] + diff --git a/Gemfile.lock b/Gemfile.lock index fa04f864dc9f7eaf199229b78c8a90c393609c78..ebcf30cabbf60209cb949f7256836b02bd0d6a59 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -262,6 +262,8 @@ GEM multi_xml (>= 0.5.2) i18n (1.13.0) concurrent-ruby (~> 1.0) + i18n_data (0.17.1) + simple_po_parser (~> 1.1) image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) @@ -475,6 +477,7 @@ GEM simple_form_password_with_hints (0.0.7) rails simple_form + simple_po_parser (1.1.6) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -589,6 +592,7 @@ DEPENDENCIES hal_openscience (~> 0.1) has_scope (~> 0.8.0) hash_dot + i18n_data (~> 0.17.1) image_processing jbuilder jquery-rails diff --git a/app/models/communication/extranet.rb b/app/models/communication/extranet.rb index 0dc31636314ab864924471003317609996665e7c..1a4615b3d6c6865f180dd318b43f9c1268235907 100644 --- a/app/models/communication/extranet.rb +++ b/app/models/communication/extranet.rb @@ -2,34 +2,35 @@ # # Table name: communication_extranets # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# color :string -# cookies_policy :text -# css :text -# feature_alumni :boolean default(FALSE) -# feature_contacts :boolean default(FALSE) -# feature_jobs :boolean default(FALSE) -# feature_library :boolean default(FALSE) -# feature_posts :boolean default(FALSE) -# has_sso :boolean default(FALSE) -# home_sentence :text -# host :string -# name :string -# privacy_policy :text -# registration_contact :string -# sass :text -# sso_button_label :string -# sso_cert :text -# sso_mapping :jsonb -# sso_name_identifier_format :string -# sso_provider :integer default("saml") -# sso_target_url :string -# terms :text -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# allow_experiences_modification :boolean default(TRUE) +# color :string +# cookies_policy :text +# css :text +# feature_alumni :boolean default(FALSE) +# feature_contacts :boolean default(FALSE) +# feature_jobs :boolean default(FALSE) +# feature_library :boolean default(FALSE) +# feature_posts :boolean default(FALSE) +# has_sso :boolean default(FALSE) +# home_sentence :text +# host :string +# name :string +# privacy_policy :text +# registration_contact :string +# sass :text +# sso_button_label :string +# sso_cert :text +# sso_mapping :jsonb +# sso_name_identifier_format :string +# sso_provider :integer default("saml") +# sso_target_url :string +# terms :text +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed # # Indexes # diff --git a/app/models/language.rb b/app/models/language.rb index 212b40dce877387634041b6a844b49bd7c2b8836..ff69a255b07e8b715eff2b6e46b914391d9c3b24 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -21,6 +21,7 @@ class Language < ApplicationRecord validates_presence_of :iso_code validates_uniqueness_of :iso_code + scope :available_for_interface, -> { where(iso_code: I18n.available_locales) } scope :ordered, -> { order(name: :asc) } def to_s diff --git a/app/services/filters/admin/users.rb b/app/services/filters/admin/users.rb index 62691ceffc6174f0550cce0442cdbe03df72a762..ff9d12c1664c803423dd0c2da2303e63a035b833 100644 --- a/app/services/filters/admin/users.rb +++ b/app/services/filters/admin/users.rb @@ -4,7 +4,7 @@ module Filters super add_search add :for_language, - ::Language.all.map { |l| { to_s: I18n.t("languages.#{l.iso_code}"), id: l.id } }, + ::Language.available_for_interface.map { |l| { to_s: I18n.t("languages.#{l.iso_code}"), id: l.id } }, I18n.t( 'filters.attributes.element', element: Language.model_name.human.downcase diff --git a/app/views/admin/application/i18n/_widget.html.erb b/app/views/admin/application/i18n/_widget.html.erb index dd235bf33dbc7a7869ba3d916d1b049b0641f4a4..4fd0ee14cfa5defcb667628962552949ade0fda6 100644 --- a/app/views/admin/application/i18n/_widget.html.erb +++ b/app/views/admin/application/i18n/_widget.html.erb @@ -7,7 +7,7 @@ <ol class="list-unstyled"> <% about.available_languages.each do |language| %> <% - label = t(language.iso_code, scope: :languages) + label = I18nData.languages(I18n.locale)[language.iso_code.to_s.upcase].titleize current = language.id == about.language_id %> <li><%= link_to_unless current, label, [*route_args, lang: language.iso_code] %></li> diff --git a/app/views/admin/communication/websites/_form.html.erb b/app/views/admin/communication/websites/_form.html.erb index 81f091f295b53880dff8aac3d8e12a80f99249a7..e61ee6a72dfc817d0df72408865b88a0bb5d2913 100644 --- a/app/views/admin/communication/websites/_form.html.erb +++ b/app/views/admin/communication/websites/_form.html.erb @@ -8,7 +8,7 @@ <%= f.input :name %> <%= f.input :url %> <%= render 'admin/communication/abouts', f: f, i18n_key: 'activerecord.attributes.communication/website.about_' %> - <%= f.association :languages, as: :check_boxes, required: true, wrapper_html: { class: "js-languages" } %> + <%= f.association :languages, as: :check_boxes, required: true, wrapper_html: { class: "js-languages" }, label_method: lambda { |l| I18nData.languages(I18n.locale)[l.iso_code.to_s.upcase].titleize } %> <%= f.association :default_language, include_blank: t('simple_form.include_blanks.defaults.language'), input_html: (@website.persisted? ? { disabled: true } : { class: "js-default-language" }) %> <%= f.input :in_production %> <% end %> diff --git a/app/views/admin/communication/websites/_sidebar.html.erb b/app/views/admin/communication/websites/_sidebar.html.erb index e2205ef3eb35121a3d565933628ca3614643d482..145a0cc093ca4cef3f1d557a01e38cc62bd88147 100644 --- a/app/views/admin/communication/websites/_sidebar.html.erb +++ b/app/views/admin/communication/websites/_sidebar.html.erb @@ -53,7 +53,7 @@ <select class="form-control form-select mt-5" onchange="if (this.value) window.location.href=this.value"> <% @website.languages.each do |language| %> <% - label = I18n.t(language.iso_code, scope: :languages) + label = I18nData.languages(I18n.locale)[language.iso_code.to_s.upcase].titleize path = url_for request.params.merge(lang: language.iso_code) selected = current_website_language == language %> diff --git a/app/views/admin/users/_form.html.erb b/app/views/admin/users/_form.html.erb index 7c0c5ea2608bf83ef11207d596bd5a779c2af41c..ca83eefc3cd3b10f36b4357947ed2692f59a7faf 100644 --- a/app/views/admin/users/_form.html.erb +++ b/app/views/admin/users/_form.html.erb @@ -9,6 +9,7 @@ <%= f.input :last_name %> <%= f.association :language, include_blank: false, + collection: Language.available_for_interface, label_method: lambda { |l| t("languages.#{l.iso_code.to_s}") } %> </div> <div class="col-md-4"> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 5bb6d917bb75447f5ad32f404aceade0130ceabe..b4142762eb6c9467ab611263674dba2b84344433 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -15,6 +15,7 @@ input_html: { autocomplete: "last_name" } %> <%= f.association :language, include_blank: false, + collection: Language.available_for_interface, label_method: lambda { |l| t("languages.#{l.iso_code.to_s}") } %> <%= f.input :admin_theme, include_blank: false %> </div> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index cc85287f0ac19054fb0b051522e7b1684be16a12..ac997c4163d04e58e50e6d6cb2a4cd94772243e2 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -19,6 +19,7 @@ input_html: { autocomplete: "last_name" } %> <%= f.association :language, required: true, + collection: Language.available_for_interface, label_method: lambda { |l| t("languages.#{l.iso_code.to_s}") }, include_blank: :translate %> </div> diff --git a/db/schema.rb b/db/schema.rb index e4fe4db68c63e33e43d5f4b835d904648853e699..7a3b26203ff13db87881df7e8ef8046f09c5f78a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -105,8 +105,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_06_14_062545) do t.datetime "updated_at", null: false t.string "title" t.boolean "published", default: true - t.uuid "heading_id" t.uuid "communication_website_id" + t.uuid "heading_id" t.index ["about_type", "about_id"], name: "index_communication_website_blocks_on_about" t.index ["communication_website_id"], name: "index_communication_blocks_on_communication_website_id" t.index ["heading_id"], name: "index_communication_blocks_on_heading_id" @@ -223,6 +223,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_06_14_062545) do t.text "home_sentence" t.text "sass" t.text "css" + t.boolean "allow_experiences_modification", default: true t.index ["about_type", "about_id"], name: "index_communication_extranets_on_about" t.index ["university_id"], name: "index_communication_extranets_on_university_id" end @@ -464,7 +465,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_06_14_062545) do t.index ["university_id"], name: "index_communication_website_pages_on_university_id" end - create_table "communication_website_permalinks", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_permalinks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.string "about_type", null: false diff --git a/test/fixtures/communication/extranets.yml b/test/fixtures/communication/extranets.yml index c4a72564511a4905256b44eff1b90d9ad95d76db..5b00f559b78ac19b9a3871e2736923e92e325c4b 100644 --- a/test/fixtures/communication/extranets.yml +++ b/test/fixtures/communication/extranets.yml @@ -2,34 +2,35 @@ # # Table name: communication_extranets # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# color :string -# cookies_policy :text -# css :text -# feature_alumni :boolean default(FALSE) -# feature_contacts :boolean default(FALSE) -# feature_jobs :boolean default(FALSE) -# feature_library :boolean default(FALSE) -# feature_posts :boolean default(FALSE) -# has_sso :boolean default(FALSE) -# home_sentence :text -# host :string -# name :string -# privacy_policy :text -# registration_contact :string -# sass :text -# sso_button_label :string -# sso_cert :text -# sso_mapping :jsonb -# sso_name_identifier_format :string -# sso_provider :integer default("saml") -# sso_target_url :string -# terms :text -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# allow_experiences_modification :boolean default(TRUE) +# color :string +# cookies_policy :text +# css :text +# feature_alumni :boolean default(FALSE) +# feature_contacts :boolean default(FALSE) +# feature_jobs :boolean default(FALSE) +# feature_library :boolean default(FALSE) +# feature_posts :boolean default(FALSE) +# has_sso :boolean default(FALSE) +# home_sentence :text +# host :string +# name :string +# privacy_policy :text +# registration_contact :string +# sass :text +# sso_button_label :string +# sso_cert :text +# sso_mapping :jsonb +# sso_name_identifier_format :string +# sso_provider :integer default("saml") +# sso_target_url :string +# terms :text +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed # # Indexes # diff --git a/test/fixtures/user/favorites.yml b/test/fixtures/user/favorites.yml index 35d99a85f9237a456a88a5ac9344982b1d80abe6..8e2a7153d68f6ddd25efbaaf00bdce5e51cb0aa2 100644 --- a/test/fixtures/user/favorites.yml +++ b/test/fixtures/user/favorites.yml @@ -18,7 +18,6 @@ # # fk_rails_25ed4cb388 (user_id => users.id) # -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: user: one