-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add batch approve/reject for pending hashtags in admin UI (#11791)
- Loading branch information
Showing
7 changed files
with
142 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters