mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 09:08:10 +08:00
FEATURE: Merge tagging plugin into core
This commit is contained in:
@ -11,7 +11,7 @@ class TopicsBulkAction
|
||||
def self.operations
|
||||
@operations ||= %w(change_category close archive change_notification_level
|
||||
reset_read dismiss_posts delete unlist archive_messages
|
||||
move_messages_to_inbox)
|
||||
move_messages_to_inbox change_tags)
|
||||
end
|
||||
|
||||
def self.register_operation(name, &block)
|
||||
@ -130,6 +130,23 @@ class TopicsBulkAction
|
||||
end
|
||||
end
|
||||
|
||||
def change_tags
|
||||
tags = @operation[:tags]
|
||||
tags = DiscourseTagging.tags_for_saving(tags, guardian) if tags.present?
|
||||
|
||||
topics.each do |t|
|
||||
if guardian.can_edit?(t)
|
||||
if tags.present?
|
||||
t.custom_fields.update(DiscourseTagging::TAGS_FIELD_NAME => tags)
|
||||
t.save
|
||||
DiscourseTagging.auto_notify_for(tags, t)
|
||||
else
|
||||
t.custom_fields.delete(DiscourseTagging::TAGS_FIELD_NAME)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def guardian
|
||||
@guardian ||= Guardian.new(@user)
|
||||
end
|
||||
|
Reference in New Issue
Block a user