Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions app/controllers/tag_wranglers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
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)
Expand Down Expand Up @@ -49,7 +51,7 @@
.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) }
Expand All @@ -63,9 +65,9 @@
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)

Check warning on line 70 in app/controllers/tag_wranglers_controller.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Use `where(name: names)` instead of manually constructing SQL. Raw Output: app/controllers/tag_wranglers_controller.rb:70:24: C: Rails/WhereEquals: Use `where(name: names)` instead of manually constructing SQL.
noncanonical_fandoms = []
if fandoms.present? && current_user.respond_to?(:fandoms)
fandoms.each do |fandom|
Expand All @@ -81,16 +83,16 @@
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
Expand Down
2 changes: 1 addition & 1 deletion app/views/tag_wranglers/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="tag wrangling wranglers home">
<!--Descriptive page name, messages and instructions-->
<h2 class="heading">Tag Wrangling Assignments</h2>
<h2 class="heading"><%= t(".page_heading") %></h2>
<!--/descriptions-->

<!--subnav-->
Expand Down
2 changes: 2 additions & 0 deletions config/locales/controllers/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/locales/views/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion features/tags_and_wrangling/tag_wrangling.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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" |
Expand Down
4 changes: 2 additions & 2 deletions features/tags_and_wrangling/tag_wrangling_more.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
Loading