Add batch approve/reject for pending hashtags in admin UI (#11791)
This commit is contained in:
parent
3feacd2b14
commit
261e52268c
7 changed files with 142 additions and 19 deletions
33
app/models/form/tag_batch.rb
Normal file
33
app/models/form/tag_batch.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Form::TagBatch
|
||||
include ActiveModel::Model
|
||||
include Authorization
|
||||
|
||||
attr_accessor :tag_ids, :action, :current_account
|
||||
|
||||
def save
|
||||
case action
|
||||
when 'approve'
|
||||
approve!
|
||||
when 'reject'
|
||||
reject!
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def tags
|
||||
Tag.where(id: tag_ids)
|
||||
end
|
||||
|
||||
def approve!
|
||||
tags.each { |tag| authorize(tag, :update?) }
|
||||
tags.update_all(trendable: true, reviewed_at: Time.now.utc)
|
||||
end
|
||||
|
||||
def reject!
|
||||
tags.each { |tag| authorize(tag, :update?) }
|
||||
tags.update_all(trendable: false, reviewed_at: Time.now.utc)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue