diff --git a/app/controllers/tag_wranglers_controller.rb b/app/controllers/tag_wranglers_controller.rb index f3359580a32..398983aa0aa 100644 --- a/app/controllers/tag_wranglers_controller.rb +++ b/app/controllers/tag_wranglers_controller.rb @@ -8,6 +8,8 @@ class TagWranglersController < ApplicationController def index authorize :wrangling, :full_access? if logged_in_as_admin? + @page_subtitle = t(".page_title") + @wranglers = Role.find_by(name: "tag_wrangler").users.alphabetical @assignments = Fandom.in_use.joins("LEFT JOIN wrangling_assignments ON (wrangling_assignments.fandom_id = tags.id) @@ -49,7 +51,7 @@ def report_csv .where(last_wrangler: wrangler) .limit(ArchiveConfig.WRANGLING_REPORT_LIMIT) .includes(:merger, :parents) - results = [%w[Name Last\ Updated Type Merger Fandoms Unwrangleable]] + results = [["Name", "Last Updated", "Type", "Merger", "Fandoms", "Unwrangleable"]] wrangled_tags.find_each(order: :desc) do |tag| merger = tag.merger&.name || "" fandoms = tag.parents.filter_map { |parent| parent.name if parent.is_a?(Fandom) } @@ -63,9 +65,9 @@ def report_csv def create authorize :wrangling if logged_in_as_admin? - unless params[:tag_fandom_string].blank? - names = params[:tag_fandom_string].gsub(/$/, ',').split(',').map(&:strip) - fandoms = Fandom.where('name IN (?)', names) + if params[:tag_fandom_string].present? + names = params[:tag_fandom_string].gsub(/$/, ",").split(",").map(&:strip) + fandoms = Fandom.where("name IN (?)", names) noncanonical_fandoms = [] if fandoms.present? && current_user.respond_to?(:fandoms) fandoms.each do |fandom| @@ -81,16 +83,16 @@ def create flash[:error] = t(".noncanonical_fandoms_tried_assignment", count: noncanonical_fandoms.length, fandom_list: helpers.to_sentence(noncanonical_fandoms.map(&:name))) unless noncanonical_fandoms.empty? end end - unless params[:assignments].blank? + if params[:assignments].present? params[:assignments].each_pair do |fandom_id, user_logins| fandom = Fandom.find(fandom_id) user_logins.uniq.each do |login| - unless login.blank? - user = User.find_by(login: login) - unless user.nil? || user.fandoms.include?(fandom) - assignment = user.wrangling_assignments.build(fandom_id: fandom.id) - assignment.save! - end + next if login.blank? + + user = User.find_by(login: login) + unless user.nil? || user.fandoms.include?(fandom) + assignment = user.wrangling_assignments.build(fandom_id: fandom.id) + assignment.save! end end end diff --git a/app/views/tag_wranglers/index.html.erb b/app/views/tag_wranglers/index.html.erb index fe5fc9da653..d237fbc97aa 100644 --- a/app/views/tag_wranglers/index.html.erb +++ b/app/views/tag_wranglers/index.html.erb @@ -1,6 +1,6 @@
-

Tag Wrangling Assignments

+

<%= t(".page_heading") %>

diff --git a/config/locales/controllers/en.yml b/config/locales/controllers/en.yml index 1f16a6dde94..7ed94cc5447 100644 --- a/config/locales/controllers/en.yml +++ b/config/locales/controllers/en.yml @@ -387,6 +387,8 @@ en: noncanonical_fandoms_tried_assignment: one: Could not assign fandom %{fandom_list}. Non-canonical fandoms cannot be assigned. other: Could not assign fandoms %{fandom_list}. Non-canonical fandoms cannot be assigned. + index: + page_title: Wranglers tag_wranglings: index: page_subtitle: fandoms diff --git a/config/locales/views/en.yml b/config/locales/views/en.yml index a83971a818d..fd2bd12c806 100644 --- a/config/locales/views/en.yml +++ b/config/locales/views/en.yml @@ -3062,6 +3062,7 @@ en: only_fandoms_starting_with: Only fandoms starting with only_media: Only media only_wrangler: Only wrangler + page_heading: Wranglers show: last_wrangled_html: "%{wrangler_login} last wrangled at %{time}." tags_wrangled_csv: Tags Wrangled (CSV) diff --git a/features/tags_and_wrangling/tag_wrangling.feature b/features/tags_and_wrangling/tag_wrangling.feature index 41755edae08..4c9caaef27a 100644 --- a/features/tags_and_wrangling/tag_wrangling.feature +++ b/features/tags_and_wrangling/tag_wrangling.feature @@ -36,7 +36,7 @@ Feature: Tag wrangling Examples: | link_text | heading | - | "Wranglers" | "Tag Wrangling Assignments" | + | "Wranglers" | "Assign Wranglers to Fandoms" | | "Wrangling Tools" | "Tag Wrangling" | | "Characters by fandom (2)" | "Mass Wrangle New/Unwrangled Tags" | | "Relationships by fandom (1)" | "Mass Wrangle New/Unwrangled Tags" | diff --git a/features/tags_and_wrangling/tag_wrangling_more.feature b/features/tags_and_wrangling/tag_wrangling_more.feature index b19cfcc48fe..13195b7f0bb 100644 --- a/features/tags_and_wrangling/tag_wrangling_more.feature +++ b/features/tags_and_wrangling/tag_wrangling_more.feature @@ -29,7 +29,7 @@ Feature: Tag wrangling: assigning wranglers, using the filters on the Wranglers Then I should see "Wrangling Home" And I should not see "first fandom" When I follow "Wranglers" - Then I should see "Tag Wrangling Assignments" + Then I should see "Assign Wranglers to Fandoms" And I should see "first fandom" When I view the tag "first fandom" Then I should see "Edit" @@ -44,7 +44,7 @@ Feature: Tag wrangling: assigning wranglers, using the filters on the Wranglers Then I should see "Wrangling Home" And I should not see "first fandom" When I follow "Wranglers" - Then I should see "Tag Wrangling Assignments" + Then I should see "Assign Wranglers to Fandoms" And I should see "first fandom" # assigning a fandom to oneself