sqm-dashboards/app/controllers/legacy/recipient_lists_controller.rb
Nelson Jovel ad03606d66 Add benchmarks to survey and admin data items. Remove them from measures. Modify seeder
Calculate benchmarks for measures based on a weighted average of survey
and admin data items

Added architectural records
2021-12-28 14:10:34 +01:00

67 lines
1.8 KiB
Ruby

module Legacy
class RecipientListsController < Legacy::ApplicationController
before_action :authenticate_user!
before_action :set_school
before_action :verify_admin
before_action :set_recipient_list, only: %i[show edit update destroy]
# GET schools/1/recipient_lists
def index
@recipient_lists = @school.recipient_lists
end
# GET schools/1/recipient_lists/1
def show; end
# GET schools/1/recipient_lists/new
def new
@recipient_list = @school.recipient_lists.build
end
# GET schools/1/recipient_lists/1/edit
def edit; end
# POST schools/1/recipient_lists
def create
@recipient_list = @school.recipient_lists.build(recipient_list_params)
if @recipient_list.save
redirect_to([@recipient_list.school, @recipient_list], notice: 'Recipient list was successfully created.')
else
render action: 'new'
end
end
# PUT schools/1/recipient_lists/1
def update
if @recipient_list.update(recipient_list_params)
redirect_to([@recipient_list.school, @recipient_list], notice: 'Recipient list was successfully updated.')
else
render action: 'edit'
end
end
# DELETE schools/1/recipient_lists/1
def destroy
@recipient_list.destroy
redirect_to @school
end
private
# Use callbacks to share common setup or constraints between actions.
def set_school
@school = Legacy::School.friendly.find(params[:school_id])
end
def set_recipient_list
@recipient_list = @school.recipient_lists.find(params[:id])
end
# Only allow a trusted parameter "white list" through.
def recipient_list_params
params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])
end
end
end