2013-11-12 07:28:12 -05:00
|
|
|
class Admin::BroadcastMessagesController < Admin::ApplicationController
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :broadcast_messages
|
2013-11-12 07:28:12 -05:00
|
|
|
|
|
|
|
def index
|
|
|
|
@broadcast_message = BroadcastMessage.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2014-06-26 08:00:09 -04:00
|
|
|
@broadcast_message = BroadcastMessage.new(broadcast_message_params)
|
2013-11-12 07:28:12 -05:00
|
|
|
|
|
|
|
if @broadcast_message.save
|
|
|
|
redirect_to admin_broadcast_messages_path, notice: 'Broadcast Message was successfully created.'
|
|
|
|
else
|
|
|
|
render :index
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-11-12 08:20:31 -05:00
|
|
|
def destroy
|
|
|
|
BroadcastMessage.find(params[:id]).destroy
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to :back }
|
|
|
|
format.js { render nothing: true }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-11-12 07:28:12 -05:00
|
|
|
protected
|
|
|
|
|
|
|
|
def broadcast_messages
|
|
|
|
@broadcast_messages ||= BroadcastMessage.order("starts_at DESC").page(params[:page])
|
|
|
|
end
|
2014-06-26 08:00:09 -04:00
|
|
|
|
|
|
|
def broadcast_message_params
|
|
|
|
params.require(:broadcast_message).permit(
|
|
|
|
:alert_type, :color, :ends_at, :font,
|
|
|
|
:message, :starts_at
|
|
|
|
)
|
|
|
|
end
|
2013-11-12 07:28:12 -05:00
|
|
|
end
|