0
0
Fork 0

Add batch approve/reject for pending hashtags in admin UI (#11791)

This commit is contained in:
Eugen Rochko 2019-09-09 12:50:09 +02:00 committed by GitHub
parent 3feacd2b14
commit 261e52268c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 142 additions and 19 deletions

View 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