Sha256: 01736e98c491d6afe8c3e4e42c0de3e9390d34595f1c4687eb0728c9788f9a94

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

class Manager::ReportsController < Manager::ManagerController

  before_action :authenticate_user!
  before_filter :set_lists

  def index
    @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]
  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

2 entries across 2 versions & 2 rubygems

Version Path
ish_lib_manager-0.0.1 app/controllers/ish_lib_manager/reports_controller.rb~
ish_lib_engine-0.0.1 app/controllers/ish_lib_engine/manager/reports_controller.rb~