Class: ReportController

Inherits:
ApplicationController show all
Defined in:
app/controllers/report_controller.rb

Overview

Copyright © 2010-2011, Diaspora Inc. This file is

licensed under the Affero General Public License version 3 or later.  See
the COPYRIGHT file.

Instance Method Summary collapse

Instance Method Details

#createObject


31
32
33
34
35
36
37
38
# File 'app/controllers/report_controller.rb', line 31

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

#destroyObject


22
23
24
25
26
27
28
29
# File 'app/controllers/report_controller.rb', line 22

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

#indexObject


11
12
13
# File 'app/controllers/report_controller.rb', line 11

def index
  @reports = Report.where(reviewed: false).all
end

#updateObject


15
16
17
18
19
20
# File 'app/controllers/report_controller.rb', line 15

def update
  if report = Report.where(id: params[:id]).first
    report.mark_as_reviewed
  end
  redirect_to :action => :index
end