debian-mirror-gitlab/app/controllers/admin/broadcast_messages_controller.rb

55 lines
1.2 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
class Admin::BroadcastMessagesController < Admin::ApplicationController
before_action :finder, only: [:edit, :update, :destroy]
2014-09-02 18:07:02 +05:30
def index
@broadcast_messages = BroadcastMessage.reorder("starts_at ASC").page(params[:page])
@broadcast_message = BroadcastMessage.new
end
def edit
2014-09-02 18:07:02 +05:30
end
def create
@broadcast_message = BroadcastMessage.new(broadcast_message_params)
if @broadcast_message.save
redirect_to admin_broadcast_messages_path, notice: 'Broadcast Message was successfully created.'
else
render :index
end
end
def update
if @broadcast_message.update(broadcast_message_params)
redirect_to admin_broadcast_messages_path, notice: 'Broadcast Message was successfully updated.'
else
render :edit
end
end
2014-09-02 18:07:02 +05:30
def destroy
@broadcast_message.destroy
2014-09-02 18:07:02 +05:30
respond_to do |format|
2015-10-24 18:46:33 +05:30
format.html { redirect_back_or_default(default: { action: 'index' }) }
2014-09-02 18:07:02 +05:30
format.js { render nothing: true }
end
end
protected
def finder
@broadcast_message = BroadcastMessage.find(params[:id])
2014-09-02 18:07:02 +05:30
end
def broadcast_message_params
params.require(:broadcast_message).permit(%i(
color
ends_at
font
message
starts_at
))
2014-09-02 18:07:02 +05:30
end
end