diff --git a/app/assets/stylesheets/commons/_forms.sass b/app/assets/stylesheets/commons/_forms.sass index 4b1f04f6b170b8ff2aaeb18ba952d2c03abb4e0a..a61cc00e3f6861e75ff75e2ed7f7daa7bd2ebeba 100644 --- a/app/assets/stylesheets/commons/_forms.sass +++ b/app/assets/stylesheets/commons/_forms.sass @@ -1,7 +1,9 @@ .password position: relative .sfpwh-password-toggle - top: calc(50% - 6px) + top: 36px +.sfpwh-controls ~ .invalid-feedback + margin-top: 0 legend ~ * clear: left diff --git a/app/helpers/admin/application_helper.rb b/app/helpers/admin/application_helper.rb index 9a6d98c6d21970fd24408faf582a748b52422ff6..cf9e2a493811202bb386eb7d9d07bc143a442fc0 100644 --- a/app/helpers/admin/application_helper.rb +++ b/app/helpers/admin/application_helper.rb @@ -24,7 +24,7 @@ module Admin::ApplicationHelper link_to options.delete(:label) || t('delete'), polymorphic_url_param(object, **options), method: :delete, - data: { confirm: t('please-confirm') }, + data: { confirm: options.delete(:confirm_message) || t('please_confirm') }, class: button_classes_danger end diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index cdb51a35bc4b3fc8ba7aa69f4af3ff4d1c46f88a..472599c29ada5c4d24429e090426f50517adf00b 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -61,7 +61,7 @@ class Communication::Website::Page < ApplicationRecord has_many :children, class_name: 'Communication::Website::Page', foreign_key: :parent_id, - dependent: :nullify + dependent: :destroy validates :title, presence: true diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 6cef3f3d82f4ea5f99cff223d9d990714f9a06a0..6f8ddcbb26013813c62769aa0fd76dab4e61d012 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -52,7 +52,7 @@ class Education::Program < ApplicationRecord has_many :children, class_name: 'Education::Program', foreign_key: :parent_id, - dependent: :nullify + dependent: :destroy has_and_belongs_to_many :schools, class_name: 'Education::School', join_table: 'education_programs_schools', @@ -95,6 +95,10 @@ class Education::Program < ApplicationRecord self.path = "#{parent&.path}/#{slug}".gsub(/\/+/, '/') end + def update_children_paths + children.each(&:save) + end + def list_of_other_programs university.list_of_programs.reject! { |p| p[:id] == id } end diff --git a/app/models/user/with_authentication.rb b/app/models/user/with_authentication.rb index dafe47ac03888754205fb42dd58353792351dde7..933ba2c8f2b7d7b67672d9da4133ceb74008266a 100644 --- a/app/models/user/with_authentication.rb +++ b/app/models/user/with_authentication.rb @@ -78,7 +78,7 @@ module User::WithAuthentication def password_complexity # Regexp extracted from https://stackoverflow.com/questions/19605150/regex-for-password-must-contain-at-least-eight-characters-at-least-one-number-a return if password.blank? || password =~ /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#{Rails.application.config.allowed_special_chars}]).{#{Devise.password_length.first},#{Devise.password_length.last}}$/ - errors.add :password, I18n.t('activerecord.errors.models.user.password.password_strength') + errors.add :password, :password_strength end end end diff --git a/app/views/admin/administration/members/_list.html.erb b/app/views/admin/administration/members/_list.html.erb index f1cdd3ffb33e745505bfa1c5430bbbbde06d5f39..7a1dcab14161c160c26ccf1c0de3670e49b65c46 100644 --- a/app/views/admin/administration/members/_list.html.erb +++ b/app/views/admin/administration/members/_list.html.erb @@ -17,7 +17,7 @@ <%= link_to t('delete'), admin_administration_member_path(member), method: :delete, - data: { confirm: t('please-confirm') }, + data: { confirm: t('please_confirm') }, class: button_classes_danger %> </div> </td> diff --git a/app/views/admin/communication/website/categories/_list.html.erb b/app/views/admin/communication/website/categories/_list.html.erb index af55dc0c97b4a5dc40501970d89356d37fe70685..25e053ef79540d24892f9c2bac35450cfc1b35ee 100644 --- a/app/views/admin/communication/website/categories/_list.html.erb +++ b/app/views/admin/communication/website/categories/_list.html.erb @@ -17,7 +17,7 @@ <%= link_to t('delete'), admin_communication_website_category_path(website_id: category.website.id, id: category.id), method: :delete, - data: { confirm: t('please-confirm') }, + data: { confirm: t('please_confirm') }, class: button_classes_danger if can?(:destroy, category) %> </div> </td> diff --git a/app/views/admin/communication/website/menu/items/_treebranch.html.erb b/app/views/admin/communication/website/menu/items/_treebranch.html.erb index 2dbc404ee6065b7225defe42f6fc36dccc945fb8..841ea52d063e69c9f50bb1a52b8a39131efee7b8 100644 --- a/app/views/admin/communication/website/menu/items/_treebranch.html.erb +++ b/app/views/admin/communication/website/menu/items/_treebranch.html.erb @@ -22,7 +22,7 @@ <%= link_to t('delete'), admin_communication_website_menu_item_path(website_id: item.website.id, menu_id: item.menu.id, id: item.id), method: :delete, - data: { confirm: t('please-confirm') }, + data: { confirm: t('please_confirm') }, class: button_classes_danger if can?(:destroy, item) %> </div> </div> diff --git a/app/views/admin/communication/website/menus/_list.html.erb b/app/views/admin/communication/website/menus/_list.html.erb index 139c6472abf20be83aac482da35a38995ba2bb0c..fa74e0adcaaa6ee23f39596c991f15b634cd81b6 100644 --- a/app/views/admin/communication/website/menus/_list.html.erb +++ b/app/views/admin/communication/website/menus/_list.html.erb @@ -17,7 +17,7 @@ <%= link_to t('delete'), admin_communication_website_menu_path(website_id: menu.website.id, id: menu.id), method: :delete, - data: { confirm: t('please-confirm') }, + data: { confirm: t('please_confirm') }, class: button_classes_danger if can?(:destroy, menu) %> </div> </td> diff --git a/app/views/admin/communication/website/pages/_list.html.erb b/app/views/admin/communication/website/pages/_list.html.erb index f704df75504bfeff23a5a2a68ebdb3039c264bbf..54d0db98d0d1448d289561f013b1da2b5314c23d 100644 --- a/app/views/admin/communication/website/pages/_list.html.erb +++ b/app/views/admin/communication/website/pages/_list.html.erb @@ -21,7 +21,7 @@ <%= link_to t('delete'), admin_communication_website_page_path(website_id: page.website.id, id: page.id), method: :delete, - data: { confirm: t('please-confirm') }, + data: { confirm: page.children.any? ? t('please_confirm_with_children') : t('please_confirm') }, class: button_classes_danger if can?(:destroy, page) %> </div> </td> diff --git a/app/views/admin/communication/website/pages/_treebranch.html.erb b/app/views/admin/communication/website/pages/_treebranch.html.erb index e85e3fd3046d21020ff61374aaa58314a0cf0710..96980e5470c33def62a2ab6a658e6e7a16499664 100644 --- a/app/views/admin/communication/website/pages/_treebranch.html.erb +++ b/app/views/admin/communication/website/pages/_treebranch.html.erb @@ -18,7 +18,7 @@ <span class="move_btn py-2 ps-2"><i class="fas fa-sort"></i></span> <div class="btn-group ms-auto" role="group"> <%= edit_link page %> - <%= destroy_link page %> + <%= destroy_link page, confirm_message: page.children.any? ? t('please_confirm_with_children') : t('please_confirm') %> </div> </div> <ul class="list-unstyled treeview__children js-treeview-children <%= 'js-treeview-sortable-container' if can?(:reorder, page) %> ms-4" data-id="<%= page.id %>"> diff --git a/app/views/admin/communication/website/posts/_list.html.erb b/app/views/admin/communication/website/posts/_list.html.erb index 210c0b54a1c8eef41f33be477b2e688927df1811..1fdddb507b588d2f5fc2824e9ff0924830c88531 100644 --- a/app/views/admin/communication/website/posts/_list.html.erb +++ b/app/views/admin/communication/website/posts/_list.html.erb @@ -45,7 +45,7 @@ <%= link_to t('delete'), admin_communication_website_post_path(website_id: post.website.id, id: post.id), method: :delete, - data: { confirm: t('please-confirm') }, + data: { confirm: t('please_confirm') }, class: button_classes_danger if can?(:destroy, post) %> </div> </td> diff --git a/app/views/admin/education/programs/_list.html.erb b/app/views/admin/education/programs/_list.html.erb index 9dc1c1600f1060c7512bca4ddf07b5d415e1415e..9c084bf7120b7192fbbc39afca013f69a590c76d 100644 --- a/app/views/admin/education/programs/_list.html.erb +++ b/app/views/admin/education/programs/_list.html.erb @@ -15,9 +15,9 @@ edit_admin_education_program_path(program), class: button_classes %> <%= link_to t('delete'), - admin_research_journal_article_path(program), + admin_education_program_path(program), method: :delete, - data: { confirm: t('please-confirm') }, + data: { confirm: program.children.any? ? t('please_confirm_with_children') : t('please_confirm') }, class: button_classes_danger %> </div> </td> diff --git a/app/views/admin/education/programs/_treebranch.html.erb b/app/views/admin/education/programs/_treebranch.html.erb index 739e18caa1d23603bff3ac683ebb68d1521d2f2e..b70fff45869b86044d84869a447edd122a9cb763 100644 --- a/app/views/admin/education/programs/_treebranch.html.erb +++ b/app/views/admin/education/programs/_treebranch.html.erb @@ -17,7 +17,7 @@ <span class="move_btn py-2 ps-2"><i class="fas fa-sort"></i></span> <div class="btn-group ms-auto" role="group"> <%= edit_link program %> - <%= destroy_link program %> + <%= destroy_link program, confirm_message: program.children.any? ? t('please_confirm_with_children') : t('please_confirm') %> </div> </div> <ul class="list-unstyled treeview__children js-treeview-children <%= 'js-treeview-sortable-container' if can?(:reorder, program) %> ms-4" data-id="<%= program.id %>"> diff --git a/app/views/admin/research/journal/articles/_list.html.erb b/app/views/admin/research/journal/articles/_list.html.erb index d5e338ea9354588dc8c48003fc30b49f1547a70d..806c59711ea40dfcf20f5d26dd7973b652984420 100644 --- a/app/views/admin/research/journal/articles/_list.html.erb +++ b/app/views/admin/research/journal/articles/_list.html.erb @@ -19,7 +19,7 @@ <%= link_to t('delete'), admin_research_journal_article_path(journal_id: article.journal, id: article), method: :delete, - data: { confirm: t('please-confirm') }, + data: { confirm: t('please_confirm') }, class: button_classes_danger %> </div> </td> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index c4981e93897a333c8502cf4d97e1b2acd4383cab..18154048713005658286cef09a3a03489defcc48 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -22,6 +22,15 @@ </div> <div class="col-md-4"> <%= f.input :password, + as: :password_with_hints, + allow_password_uncloaking: true, + validators: { + length: Devise.password_length.first, + uppercase_char: true, + lowercase_char: true, + numeric_char: true, + special_char: Rails.application.config.allowed_special_chars + }, hint: t(".leave_blank_if_you_don_t_want_to_change_it"), required: false, input_html: { autocomplete: "new-password" } %> diff --git a/app/views/server/languages/index.html.erb b/app/views/server/languages/index.html.erb index 9f9d5506a2b3acb63e85e3a27de6c4114a552dd1..5a26dd08137ad674666e8e1eb9f4c808a118fdec 100644 --- a/app/views/server/languages/index.html.erb +++ b/app/views/server/languages/index.html.erb @@ -22,7 +22,7 @@ <%= link_to t('delete'), server_language_path(language), method: :delete, - data: { confirm: t('please-confirm') }, + data: { confirm: t('please_confirm') }, class: button_classes_danger %> </div> </td> diff --git a/app/views/server/universities/index.html.erb b/app/views/server/universities/index.html.erb index 8f7a02c7e4b9cc0d777e942862f2443353295e19..75b999cfd6fa726bcdaac2ce53ce56a4245c2c33 100644 --- a/app/views/server/universities/index.html.erb +++ b/app/views/server/universities/index.html.erb @@ -23,7 +23,7 @@ <%= link_to t('delete'), server_university_path(university), method: :delete, - data: { confirm: t('please-confirm') }, + data: { confirm: t('please_confirm') }, class: button_classes_danger %> </div> </td> diff --git a/config/locales/en.yml b/config/locales/en.yml index 18ec715033922059c6e1546f7d902953901a992c..63a99d4280fc5b80ae95774fdbd0c1a7eaf1a4bb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -26,6 +26,12 @@ en: mobile_phone: Mobile phone picture: Profile picture role: Role + errors: + models: + user: + attributes: + password: + password_strength: doesn't match the security policy models: language: one: Language @@ -103,7 +109,8 @@ en: server_admin: Admin server sign_out: Log out metadata: Metadata - please-confirm: Are you sure? + please_confirm: Are you sure? + please_confirm_with_children: "WARNING: deleting this element will also remove every child. Are you sure?" privacy_policy: Privacy policy privacy_policy_url: https://osuny.org/politique-de-confidentialite save: Save diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 0f603b7c6a343942ffd1ee5145cf563229286af5..72edb70922867a50cfb5596e575e0c7f822adf9b 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -26,6 +26,12 @@ fr: mobile_phone: Téléphone portable picture: Photo de profil role: Rôle + errors: + models: + user: + attributes: + password: + password_strength: ne répond pas aux critères de sécurité models: language: one: Langue @@ -103,7 +109,8 @@ fr: server_admin: Admin serveur sign_out: Déconnexion metadata: Informations - please-confirm: Est-ce que vous confirmez ? + please_confirm: Est-ce que vous confirmez ? + please_confirm_with_children: "ATTENTION : effacer cet élément supprimera aussi tous ses enfants. Est-ce que vous confirmez ?" privacy_policy: Politique de confidentialité privacy_policy_url: https://osuny.org/politique-de-confidentialite save: Enregistrer