mirror of https://github.com/mastodon/mastodon
Show reported collections in moderation interface (#37898)
parent
6f859364fb
commit
e288bf6516
@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class CollectionsController < BaseController
|
||||
before_action :set_account
|
||||
before_action :set_collection, only: :show
|
||||
|
||||
def show
|
||||
authorize @collection, :show?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_account
|
||||
@account = Account.find(params[:account_id])
|
||||
end
|
||||
|
||||
def set_collection
|
||||
@collection = @account.collections.includes(accepted_collection_items: :account).find(params[:id])
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,21 @@
|
||||
- content_for :page_title do
|
||||
= t('admin.collections.collection_title', name: @account.pretty_acct)
|
||||
|
||||
- content_for :heading_actions do
|
||||
= link_to t('admin.collections.open'), account_collection_path(@account, @collection), class: 'button', target: '_blank', rel: 'noopener'
|
||||
|
||||
%h3= t('admin.collections.contents')
|
||||
|
||||
= render 'admin/shared/collection', collection: @collection
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
%h3= t('admin.collections.accounts')
|
||||
|
||||
.batch-table
|
||||
.batch-table__toolbar
|
||||
.batch-table__body
|
||||
- if @collection.accepted_collection_items.none?
|
||||
= nothing_here 'nothing-here--under-tabs'
|
||||
- else
|
||||
= render partial: 'admin/accounts/account', collection: @collection.accepted_collection_items.map(&:account)
|
||||
@ -0,0 +1,22 @@
|
||||
.status__card
|
||||
- if collection.tag.present?
|
||||
.status__prepend
|
||||
= link_to collection.tag.formatted_name, admin_tag_path(collection.tag_id)
|
||||
|
||||
.status__content
|
||||
%h6= collection.name
|
||||
|
||||
%p= collection.description
|
||||
|
||||
.detailed-status__meta
|
||||
= conditional_link_to can?(:show, collection), admin_account_collection_path(collection.account.id, collection), class: 'detailed-status__datetime' do
|
||||
%time.formatted{ datetime: collection.created_at.iso8601, title: l(collection.created_at) }><= l(collection.created_at)
|
||||
- if collection.sensitive?
|
||||
·
|
||||
= material_symbol('visibility_off')
|
||||
= t('stream_entries.sensitive_content')
|
||||
·
|
||||
= t('admin.collections.number_of_accounts', count: collection.accepted_collection_items.size)
|
||||
·
|
||||
= link_to account_collection_path(collection.account, collection), class: 'detailed-status__link', target: 'blank', rel: 'noopener' do
|
||||
= t('admin.collections.view_publicly')
|
||||
@ -0,0 +1,5 @@
|
||||
.batch-table__row
|
||||
%label.batch-table__row__select.batch-checkbox
|
||||
-# = f.check_box :collection_ids, { multiple: true, include_hidden: false }, collection.id
|
||||
.batch-table__row__content
|
||||
= render partial: 'admin/shared/collection', object: collection
|
||||
@ -0,0 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Collections' do
|
||||
describe 'GET /admin/accounts/:account_id/collections/:id' do
|
||||
let(:collection) { Fabricate(:collection) }
|
||||
|
||||
before do
|
||||
sign_in Fabricate(:admin_user)
|
||||
end
|
||||
|
||||
it 'returns success' do
|
||||
get admin_account_collection_path(collection.account_id, collection)
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,68 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Reports' do
|
||||
describe 'GET /admin/reports' do
|
||||
before do
|
||||
sign_in Fabricate(:admin_user)
|
||||
|
||||
Fabricate.times(2, :report)
|
||||
end
|
||||
|
||||
it 'returns success' do
|
||||
get admin_reports_path
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /admin/reports/:id' do
|
||||
let(:report) { Fabricate(:report) }
|
||||
|
||||
before do
|
||||
sign_in Fabricate(:admin_user)
|
||||
end
|
||||
|
||||
shared_examples 'successful return' do
|
||||
it 'returns success' do
|
||||
get admin_report_path(report)
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a simple report' do
|
||||
it_behaves_like 'successful return'
|
||||
end
|
||||
|
||||
context 'with a reported status' do
|
||||
before do
|
||||
status = Fabricate(:status, account: report.target_account)
|
||||
report.update(status_ids: [status.id])
|
||||
end
|
||||
|
||||
it_behaves_like 'successful return'
|
||||
end
|
||||
|
||||
context 'with a reported collection', feature: :collections do
|
||||
before do
|
||||
report.collections << Fabricate(:collection, account: report.target_account)
|
||||
end
|
||||
|
||||
it_behaves_like 'successful return'
|
||||
end
|
||||
|
||||
context 'with both status and collection', feature: :collections do
|
||||
before do
|
||||
status = Fabricate(:status, account: report.target_account)
|
||||
report.update(status_ids: [status.id])
|
||||
report.collections << Fabricate(:collection, account: report.target_account)
|
||||
end
|
||||
|
||||
it_behaves_like 'successful return'
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue