2017-02-15 17:28:10 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-10 12:27:03 -07:00
|
|
|
module Admin
|
|
|
|
class ReportsController < BaseController
|
|
|
|
before_action :set_report, except: [:index]
|
|
|
|
|
|
|
|
def index
|
2017-11-11 11:23:33 -08:00
|
|
|
authorize :report, :index?
|
2017-04-14 02:10:28 -07:00
|
|
|
@reports = filtered_reports.page(params[:page])
|
2017-04-10 12:27:03 -07:00
|
|
|
end
|
|
|
|
|
2017-07-18 07:38:22 -07:00
|
|
|
def show
|
2017-11-11 11:23:33 -08:00
|
|
|
authorize @report, :show?
|
2018-04-19 17:28:48 -07:00
|
|
|
|
|
|
|
@report_note = @report.notes.new
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 11:02:09 -08:00
|
|
|
@report_notes = (@report.notes.latest + @report.history + @report.target_account.targeted_account_warnings.latest.custom).sort_by(&:created_at)
|
2018-04-19 17:28:48 -07:00
|
|
|
@form = Form::StatusBatch.new
|
2017-07-18 07:38:22 -07:00
|
|
|
end
|
2017-04-10 12:27:03 -07:00
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 11:02:09 -08:00
|
|
|
def assign_to_self
|
2017-11-11 11:23:33 -08:00
|
|
|
authorize @report, :update?
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 11:02:09 -08:00
|
|
|
@report.update!(assigned_account_id: current_account.id)
|
|
|
|
log_action :assigned_to_self, @report
|
|
|
|
redirect_to admin_report_path(@report)
|
2017-04-10 12:27:03 -07:00
|
|
|
end
|
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 11:02:09 -08:00
|
|
|
def unassign
|
|
|
|
authorize @report, :update?
|
|
|
|
@report.update!(assigned_account_id: nil)
|
|
|
|
log_action :unassigned, @report
|
|
|
|
redirect_to admin_report_path(@report)
|
2017-04-10 12:27:03 -07:00
|
|
|
end
|
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 11:02:09 -08:00
|
|
|
def reopen
|
|
|
|
authorize @report, :update?
|
|
|
|
@report.unresolve!
|
|
|
|
log_action :reopen, @report
|
|
|
|
redirect_to admin_report_path(@report)
|
2017-04-10 12:27:03 -07:00
|
|
|
end
|
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 11:02:09 -08:00
|
|
|
def resolve
|
|
|
|
authorize @report, :update?
|
|
|
|
@report.resolve!(current_account)
|
|
|
|
log_action :resolve, @report
|
|
|
|
redirect_to admin_reports_path, notice: I18n.t('admin.reports.resolved_msg')
|
2017-04-14 02:10:28 -07:00
|
|
|
end
|
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 11:02:09 -08:00
|
|
|
private
|
|
|
|
|
2017-04-14 02:10:28 -07:00
|
|
|
def filtered_reports
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 11:02:09 -08:00
|
|
|
ReportFilter.new(filter_params).results.order(id: :desc).includes(:account, :target_account)
|
2017-04-14 02:10:28 -07:00
|
|
|
end
|
|
|
|
|
2017-04-18 10:36:18 -07:00
|
|
|
def filter_params
|
|
|
|
params.permit(
|
|
|
|
:account_id,
|
|
|
|
:resolved,
|
|
|
|
:target_account_id
|
|
|
|
)
|
2017-04-14 02:10:28 -07:00
|
|
|
end
|
2017-04-10 12:27:03 -07:00
|
|
|
|
|
|
|
def set_report
|
|
|
|
@report = Report.find(params[:id])
|
|
|
|
end
|
2017-02-16 15:42:52 -08:00
|
|
|
end
|
2017-02-15 17:28:10 -08:00
|
|
|
end
|