post replacements: add "Tags" field to dialog box.
* Adds a "Tags" field to the post replacement dialog box. The given tags are added to the post after replacement. * Prefills the Tags field with certain tags that usually need to be removed after replacement: replaceme, image_sample, jpeg_artifacts, etc.
This commit is contained in:
@@ -4,11 +4,12 @@ class PostReplacement < ApplicationRecord
|
||||
belongs_to :post
|
||||
belongs_to :creator, class_name: "User"
|
||||
before_validation :initialize_fields
|
||||
attr_accessor :replacement_file, :final_source
|
||||
attr_accessor :replacement_file, :final_source, :tags
|
||||
|
||||
def initialize_fields
|
||||
self.creator = CurrentUser.user
|
||||
self.original_url = post.source
|
||||
self.tags = post.tag_string + " " + self.tags.to_s
|
||||
end
|
||||
|
||||
def undo!
|
||||
@@ -23,7 +24,7 @@ class PostReplacement < ApplicationRecord
|
||||
end
|
||||
|
||||
transaction do
|
||||
upload = Upload.create!(file: replacement_file, source: replacement_url, rating: post.rating, tag_string: post.tag_string)
|
||||
upload = Upload.create!(file: replacement_file, source: replacement_url, rating: post.rating, tag_string: self.tags)
|
||||
upload.process_upload
|
||||
upload.update(status: "completed", post_id: post.id)
|
||||
|
||||
@@ -155,6 +156,12 @@ class PostReplacement < ApplicationRecord
|
||||
truncated_source
|
||||
end
|
||||
end
|
||||
|
||||
def suggested_tags_for_removal
|
||||
tags = post.tag_array.select { |tag| Danbooru.config.remove_tag_after_replacement?(tag) }
|
||||
tags = tags.map { |tag| "-#{tag}" }
|
||||
tags.join(" ")
|
||||
end
|
||||
end
|
||||
|
||||
include PresenterMethods
|
||||
|
||||
Reference in New Issue
Block a user