diaspora/app/controllers/report_controller.rb
Florian Staudacher 13b716a449 allow admins to close user accounts from the backend
* thanks to @maxwell for the initial work on this

port admin pages to bootstrap
* improve user view on admin search page
* add 'close account' link to each user in the search results
* keep the same blue color for the admin menu

some refactoring of the routes and the admin code
* try to be more RESTful (possibly)
* use a 'UserSearch' model for search parameters and querying

add changelog entry
2014-07-01 23:33:15 +02:00

44 lines
1.1 KiB
Ruby

# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class ReportController < ApplicationController
before_filter :authenticate_user!
before_filter :redirect_unless_admin, :except => [:create]
use_bootstrap_for :index
def index
@reports = Report.where(reviewed: false).all
end
def update
if report = Report.where(id: params[:id]).first
report.mark_as_reviewed
end
redirect_to :action => :index
end
def destroy
if (report = Report.where(id: params[:id]).first) && report.destroy_reported_item
flash[:notice] = I18n.t 'report.status.destroyed'
else
flash[:error] = I18n.t 'report.status.failed'
end
redirect_to :action => :index
end
def create
report = current_user.reports.new(report_params)
if report.save
render :json => true, :status => 200
else
render :nothing => true, :status => 409
end
end
private
def report_params
params.require(:report).permit(:item_id, :item_type, :text)
end
end