call4paperz/call4paperz

View on GitHub
app/controllers/event_close_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
class EventCloseController < ApplicationController
  before_action :authenticate_user!
  before_action :event

  def edit
    if event.closed?
      render 'warning_reopen'
    else
      render 'warning_closing'
    end
  end

  def update
    if params[:close] == "true"
      event.close!
      redirect_to event_path(event), notice: t('flash.notice.closed')
    else
      event.reopen!
      redirect_to event_path(event), notice: t('flash.notice.reopened')
    end
  end

  private

  def event
    @event ||= current_user.events.find(params[:event_id])
  end
end