From b93383ed79ba2ae327c4e615e1a87fdbaf8a52d0 Mon Sep 17 00:00:00 2001 From: pranav-027 Date: Wed, 29 Jan 2025 13:20:24 +0530 Subject: [PATCH 1/4] Fixed grammatically incorrect message while accessing pages without permissions --- app/controllers/application_controller.rb | 7 ++++++- config/locales/en.yml | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c17f629e7a4..4dc1511a949 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -94,7 +94,12 @@ def doorkeeper_unauthorized_render_options(error: nil) def redirect_to_root_unless_user(action, *) redirecting = !current_user&.send(action, *) if redirecting - flash[:danger] = "You are not allowed to #{action.to_s.sub(/^can_/, '').chomp('?').humanize.downcase}" + flash[:danger] = case action + when :has_permission? + t("application.no_permission") + else + "You are not allowed to #{action.to_s.sub(/^can_/, '').chomp('?').humanize.downcase}" + end redirect_to root_url end redirecting diff --git a/config/locales/en.yml b/config/locales/en.yml index 272d37cc7b7..7eaba54b9f9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2879,3 +2879,5 @@ en: missing_scrambles_for_multi_error: "[%{round_id}] While you may have multiple groups in 3x3x3 Multi-Blind, at least one of the groups must contain scrambles for all attempts." multiple_fmc_groups_warning: "[%{round_id}] There are multiple groups of FMC used. If one group of FMC was used, please use the Scrambles Matcher to uncheck the unused scrambles. Otherwise, please include a comment to WRT explaining why multiple groups of FMC were used." wrong_number_of_scramble_sets_error: "[%{round_id}] This round has a different number of scramble sets than specified on the Manage Events tab. Please adjust the number of scramble sets in the Manage Events tab to the number of sets that were used." + application: + no_permission: "You do not have the required permissions to access this page." From 6e443ecdaf35a355dcc69f3becfc0b844cffeae4 Mon Sep 17 00:00:00 2001 From: pranav-027 Date: Wed, 29 Jan 2025 17:05:49 +0530 Subject: [PATCH 2/4] key fix --- app/controllers/application_controller.rb | 2 +- config/locales/en.yml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4dc1511a949..cbfce518a37 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -96,7 +96,7 @@ def redirect_to_root_unless_user(action, *) if redirecting flash[:danger] = case action when :has_permission? - t("application.no_permission") + t("errors.messages.no_permission.no_permission") else "You are not allowed to #{action.to_s.sub(/^can_/, '').chomp('?').humanize.downcase}" end diff --git a/config/locales/en.yml b/config/locales/en.yml index 7eaba54b9f9..33d2ee9dabf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -586,6 +586,7 @@ en: wrong_size: "is the wrong size (should be %{file_size})" size_too_small: "is too small (should be at least %{file_size})" size_too_big: "is too big (should be at most %{file_size})" + no_permission: "You do not have the required permissions to access this page." devise: #context: Overridden key for sign in passwords: @@ -2879,5 +2880,3 @@ en: missing_scrambles_for_multi_error: "[%{round_id}] While you may have multiple groups in 3x3x3 Multi-Blind, at least one of the groups must contain scrambles for all attempts." multiple_fmc_groups_warning: "[%{round_id}] There are multiple groups of FMC used. If one group of FMC was used, please use the Scrambles Matcher to uncheck the unused scrambles. Otherwise, please include a comment to WRT explaining why multiple groups of FMC were used." wrong_number_of_scramble_sets_error: "[%{round_id}] This round has a different number of scramble sets than specified on the Manage Events tab. Please adjust the number of scramble sets in the Manage Events tab to the number of sets that were used." - application: - no_permission: "You do not have the required permissions to access this page." From abb1efc207b978e89f513515e97c31b194508897 Mon Sep 17 00:00:00 2001 From: pranav-027 Date: Wed, 29 Jan 2025 17:06:20 +0530 Subject: [PATCH 3/4] key fix #2 --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cbfce518a37..fba845f6008 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -96,7 +96,7 @@ def redirect_to_root_unless_user(action, *) if redirecting flash[:danger] = case action when :has_permission? - t("errors.messages.no_permission.no_permission") + t("errors.messages.no_permission") else "You are not allowed to #{action.to_s.sub(/^can_/, '').chomp('?').humanize.downcase}" end From f866ef1b311b66ce040ce32453cea020aca01e87 Mon Sep 17 00:00:00 2001 From: pranav-027 Date: Mon, 3 Feb 2025 11:24:42 +0530 Subject: [PATCH 4/4] switch -> if else --- app/controllers/application_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fba845f6008..36a502fab8d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -94,8 +94,7 @@ def doorkeeper_unauthorized_render_options(error: nil) def redirect_to_root_unless_user(action, *) redirecting = !current_user&.send(action, *) if redirecting - flash[:danger] = case action - when :has_permission? + flash[:danger] = if action == :has_permission? t("errors.messages.no_permission") else "You are not allowed to #{action.to_s.sub(/^can_/, '').chomp('?').humanize.downcase}"