docbrown/app/controllers/internal/broadcasts_controller.rb
Vaidehi Joshi 3bc0f49861
Only send notifications that belong to an active broadcast (#6319) [deploy]
* Use active in place of sent on internal broadcast routes

* Add and use active scope on broadcasts

* Update seeds + specs to use active broadcasts

* Add note about active broadcasts to /internal/broadcasts page
2020-02-27 08:02:45 -08:00

36 lines
726 B
Ruby

class Internal::BroadcastsController < Internal::ApplicationController
layout "internal"
def create
@broadcast = Broadcast.create!(broadcast_params)
redirect_to "/internal/broadcasts"
end
def update
@broadcast = Broadcast.find_by!(id: params[:id])
@broadcast.update!(broadcast_params)
redirect_to "/internal/broadcasts"
end
def new
@broadcast = Broadcast.new
end
def edit
@broadcast = Broadcast.find_by!(id: params[:id])
end
def index
@broadcasts = Broadcast.all
end
private
def broadcast_params
params.permit(:title, :processed_html, :type_of, :active)
end
def authorize_admin
authorize Broadcast, :access?, policy_class: InternalPolicy
end
end