demarches-normaliennes/app/controllers/administrations_controller.rb

40 lines
915 B
Ruby
Raw Normal View History

2016-02-23 16:51:24 +01:00
class AdministrationsController < ApplicationController
include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper
before_action :authenticate_administration!
def index
2016-04-19 10:41:23 +02:00
@admin = Administrateur.new
2016-02-23 16:51:24 +01:00
@admins = smart_listing_create :admins,
2017-06-12 13:49:51 +02:00
Administrateur.all.order(:email),
partial: "administrations/list",
array: true
2016-02-23 16:51:24 +01:00
end
def create
administrateur = current_administration.invite_admin(create_administrateur_params[:email])
2016-02-23 16:51:24 +01:00
if administrateur.errors.empty?
2016-02-23 16:51:24 +01:00
flash.notice = "Administrateur créé"
else
flash.alert = administrateur.errors.full_messages
2016-02-23 16:51:24 +01:00
end
redirect_to administrations_path
end
def update
Administrateur.find_inactive_by_id(params[:id]).invite!
redirect_to administrations_path
end
2016-02-23 16:51:24 +01:00
private
def create_administrateur_params
params.require(:administrateur).permit(:email)
2016-02-23 16:51:24 +01:00
end
end