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 |
||||
= link_to admin_tag_path(tag.id) do |
||||
%h4 |
||||
= fa_icon 'hashtag' |
||||
= tag.name |
||||
.batch-table__row |
||||
%label.batch-table__row__select.batch-table__row__select--aligned.batch-checkbox |
||||
= f.check_box :tag_ids, { multiple: true, include_hidden: false }, tag.id |
||||
|
||||
%small |
||||
= t('admin.tags.in_directory', count: tag.accounts_count) |
||||
• |
||||
= t('admin.tags.unique_uses_today', count: tag.history.first[:accounts]) |
||||
.directory__tag |
||||
= link_to admin_tag_path(tag.id) do |
||||
%h4 |
||||
= fa_icon 'hashtag' |
||||
= tag.name |
||||
|
||||
- if tag.trending? |
||||
= fa_icon 'fire fw' |
||||
= t('admin.tags.trending_right_now') |
||||
%small |
||||
= t('admin.tags.in_directory', count: tag.accounts_count) |
||||
• |
||||
= 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