Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #759 from CristinaRO/bookmark_tags_with_master
Bookmark tags with master
- Loading branch information
Showing
14 changed files
with
553 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class UnsortedTagsController < ApplicationController | ||
|
||
before_filter :check_user_status | ||
before_filter :check_permission_to_wrangle | ||
|
||
def index | ||
@tags = UnsortedTag.page(params[:page]) | ||
@counts = {} | ||
[Fandom, Character, Relationship, Freeform].each do |klass| | ||
@counts[klass.to_s.downcase.pluralize.to_sym] = klass.unwrangled.in_use.count | ||
end | ||
end | ||
|
||
def mass_update | ||
unless params[:tags].blank? | ||
params[:tags].delete_if {|tag_id, tag_type| tag_type.blank? } | ||
tags = UnsortedTag.find(params[:tags].keys) | ||
tags.each do |tag| | ||
new_type = params[:tags][tag.id.to_s] | ||
if %w(Fandom Character Relationship Freeform).include?(new_type) | ||
tag.update_attribute(:type, new_type) | ||
else | ||
raise ts("#{new_type} is not a valid tag type") | ||
end | ||
end | ||
flash[:notice] = ts("Tags were successfully sorted.") | ||
end | ||
redirect_to unsorted_tags_path | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class UnsortedTag < Tag | ||
|
||
NAME = "Unsorted Tag" | ||
|
||
# unsorted tags can have their type changed | ||
# but they need to be reloaded to be seen as an instance of the proper subclass | ||
def recategorize(new_type) | ||
self.update_attribute(:type, new_type) | ||
# return a new instance of the tag, with the correct class | ||
Tag.find(self.id) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.