From 7231627193b9c27d914eb6596ef19630fff59b31 Mon Sep 17 00:00:00 2001 From: welp Date: Sun, 22 Dec 2024 22:00:09 -0800 Subject: [PATCH] Fix rubocop complaints --- app/controllers/tags_controller.rb | 18 +++++++++--------- config/locales/controllers/en.yml | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index d318d9ae46..006c63cde8 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -60,22 +60,22 @@ def show @page_subtitle = @tag.name if @tag.is_a?(Banned) if !logged_in_as_admin? - flash[:error] = ts('Please log in as admin') + flash[:error] = t("admin.access.not_admin_denied") redirect_to(tag_wranglings_path) && return elsif !policy(:wrangling).read_access? - flash[:error] = ts('Sorry, only an authorized admin can access the page you were trying to reach.') + flash[:error] = t("admin.access.page_access_denied") redirect_to(root_path) && return end end # if tag is NOT wrangled, prepare to show works and bookmarks that are using it if !@tag.canonical && !@tag.merger - if logged_in? # current_user.is_a?User - @works = @tag.works.visible_to_registered_user.paginate(page: params[:page]) - elsif logged_in_as_admin? - @works = @tag.works.visible_to_admin.paginate(page: params[:page]) - else - @works = @tag.works.visible_to_all.paginate(page: params[:page]) - end + @works = if logged_in? # current_user.is_a?User + @tag.works.visible_to_registered_user.paginate(page: params[:page]) + elsif logged_in_as_admin? + @tag.works.visible_to_admin.paginate(page: params[:page]) + else + @tag.works.visible_to_all.paginate(page: params[:page]) + end @bookmarks = @tag.bookmarks.visible.paginate(page: params[:page]) end # cache the children, since it's a possibly massive query diff --git a/config/locales/controllers/en.yml b/config/locales/controllers/en.yml index b310e50079..45fa9ddfb2 100644 --- a/config/locales/controllers/en.yml +++ b/config/locales/controllers/en.yml @@ -3,6 +3,7 @@ en: admin: access: action_access_denied: Sorry, only an authorized admin can do that. + not_admin_denied: Please log in as admin page_access_denied: Sorry, only an authorized admin can access the page you were trying to reach. admin_invitations: find: