Add batch approve/reject for pending hashtags in admin UI (#11791)
parent
3feacd2b14
commit
261e52268c
@ -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
|
@ -1,16 +1,20 @@
|
|||||||
.directory__tag
|
.batch-table__row
|
||||||
= link_to admin_tag_path(tag.id) do
|
%label.batch-table__row__select.batch-table__row__select--aligned.batch-checkbox
|
||||||
%h4
|
= f.check_box :tag_ids, { multiple: true, include_hidden: false }, tag.id
|
||||||
= fa_icon 'hashtag'
|
|
||||||
= tag.name
|
|
||||||
|
|
||||||
%small
|
.directory__tag
|
||||||
= t('admin.tags.in_directory', count: tag.accounts_count)
|
= link_to admin_tag_path(tag.id) do
|
||||||
•
|
%h4
|
||||||
= t('admin.tags.unique_uses_today', count: tag.history.first[:accounts])
|
= fa_icon 'hashtag'
|
||||||
|
= tag.name
|
||||||
|
|
||||||
- if tag.trending?
|
%small
|
||||||
= fa_icon 'fire fw'
|
= t('admin.tags.in_directory', count: tag.accounts_count)
|
||||||
= t('admin.tags.trending_right_now')
|
•
|
||||||
|
= t('admin.tags.unique_uses_today', count: tag.history.first[:accounts])
|
||||||
|
|
||||||
.trends__item__current= number_to_human tag.history.first[:uses], strip_insignificant_zeros: true
|
- if tag.trending?
|
||||||
|
= fa_icon 'fire fw'
|
||||||
|
= t('admin.tags.trending_right_now')
|
||||||
|
|
||||||
|
.trends__item__current= number_to_human tag.history.first[:uses], strip_insignificant_zeros: true
|
||||||
|
Loading…
Reference in new issue