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,
|
2016-04-19 10:41:23 +02:00
|
|
|
Administrateur.all.order(:email),
|
2016-02-23 16:51:24 +01:00
|
|
|
partial: "administrations/list",
|
|
|
|
array: true
|
|
|
|
|
2016-04-19 10:41:23 +02:00
|
|
|
|
2016-02-23 16:51:24 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
admin = Administrateur.new create_administrateur_params
|
|
|
|
|
|
|
|
if admin.save
|
|
|
|
flash.notice = "Administrateur créé"
|
|
|
|
NewAdminMailer.new_admin_email(admin, params[:administrateur][:password]).deliver_now!
|
|
|
|
else
|
|
|
|
flash.alert = admin.errors.full_messages.join('<br>').html_safe
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to administrations_path
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def create_administrateur_params
|
|
|
|
params.require(:administrateur).permit(:email, :password)
|
|
|
|
end
|
|
|
|
end
|