Sha256: c2c9c9f8836942036cd50b7c234b8aecd2e226b7472eac2a84298293f1b8b110

Contents?: true

Size: 1.6 KB

Versions: 40

Compression:

Stored size: 1.6 KB

Contents

class Wco::ReportsController < Wco::ApplicationController

  before_action :set_lists

  def create
    params[:report][:tag_ids]&.delete ''

    @report = Wco::Report.new params[:report].permit!
    authorize! :create, @report
    @report.author = current_profile
    if @report.save
      flash_notice "created report"
    else
      flash_alert "Cannot create report: #{@report.errors.messages}"
    end
    redirect_to action: 'index'
  end

  def destroy
    @report = Wco::Report.find params[:id]
    authorize! :destroy, @report
    if @report.destroy
      flash_notice 'ok'
    else
      flash_alert 'No luck.'
    end
    redirect_to action: 'index'
  end

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

  def index
    authorize! :index, Wco::Report
    @reports = Wco::Report.all.page( params[:reports_page] ).per( current_profile.per_page )
    if params[:deleted]
      @reports = Wco::Report.unscoped.where( :deleted_at.ne => nil )
    end
  end

  def new
    authorize! :new, Wco::Report
    @new_report = Wco::Report.new
  end

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

  def update
    params[:report][:tag_ids]&.delete ''

    @report = Wco::Report.unscoped.find params[:id]
    authorize! :update, @report
    if @report.update params[:report].permit!
      flash_notice "updated report"
    else
      flash_alert "Cannot update report: #{@report.errors.messages}"
    end
    redirect_to action: 'index'
  end

  ##
  ## private
  ##
  private

  def set_lists
    @tags_list = Wco::Tag.list
  end

end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
wco_models-3.1.0.202 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.201 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.199 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.198 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.197 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.196 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.195 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.194 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.193 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.192 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.191 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.190 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.189 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.188 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.187 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.184 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.183 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.182 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.181 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.180 app/controllers/wco/reports_controller.rb