Sha256: 8ffd9477326cba52e9990534c9bdee9dd390f573a67ce3d0d0167b9609b1b31f

Contents?: true

Size: 1.72 KB

Versions: 21

Compression:

Stored size: 1.72 KB

Contents

class IshManager::ReportsController < IshManager::ApplicationController

  # before_filter :authenticate_user!
  # before_filter :set_lists

  def index
    authorize! :index, Report
    @reports = Report.unscoped.where( :is_trash => false ).page( params[:reports_page] ).per( Report::PER_PAGE )
    if false === params[:site]
      @reports = @reports.where( :site_id => nil )
    end
    if params[:site_id]
      @site = Site.find params[:site_id]
      @reports = @reports.where( :site_id => params[:site_id] )
    end
  end

  def show
    @report = Report.unscoped.where({ :is_trash => false }).find params[:id]
    authorize! :show, @report
  end

  def edit
    @report = Report.unscoped.find params[:id]
  end

  def destroy
    @report = Report.unscoped.find params[:id]
    @report.is_trash = true
    @report.save
    redirect_to request.referrer
  end

  def update
    @report = Report.unscoped.find params[:id]
    authorize! :update, @report

    # photo
    photo = Photo.new
    photo.photo = params[:report][:photo]
    photo.report_id = @report.id
    photo.user = @report.user
    photo.is_public = @report.is_public
    photo.is_trash = false
    photo.save
    @report.photo = photo
    params[:report][:photo] = nil

    respond_to do |format|
      if @report.update_attributes(params[:report].permit( :name, :subhead, :descr, :venue, :city, :x, :y, :tag, :is_public, :photo, :site, :site_id ))
        format.html do
          redirect_to manager_report_path(@report), :notice => 'Report was successfully updated.'
        end
        format.json { head :ok }
      else
        format.html { render :action => "edit" }
        format.json { render :json => @report.errors, :status => :unprocessable_entity }
      end
    end
  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
ish_manager-0.1.8.16 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.15 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.14 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.13 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.12 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.11 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.10 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.9 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.8 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.7 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.6 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.5 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.4 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.3 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8.2 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.8 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.7 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.6 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.3 app/controllers/ish_manager/reports_controller.rb
ish_manager-0.1.2 app/controllers/ish_manager/reports_controller.rb