50 lines
1.0 KiB
Ruby
50 lines
1.0 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
|
|
class Public::RegistrantsController < ApplicationController
|
|
|
|
layout "public"
|
|
|
|
|
|
|
|
def create
|
|
|
|
@registrant = Registrant.new(params.require(:registrant).permit(:surname, :email))
|
|
|
|
test = Registrant.find_by_email(@registrant.email)
|
|
if test
|
|
@registrant = test
|
|
General.confirm_email(@registrant).deliver
|
|
else
|
|
|
|
if @registrant.save
|
|
General.confirm_email(@registrant).deliver
|
|
else
|
|
render :action => :new
|
|
end
|
|
end
|
|
end
|
|
|
|
def destroy_e
|
|
@registrant = Registrant.find_by_token(params[:id])
|
|
if @registrant
|
|
@registrant.destroy
|
|
@message = "<p>Vous avez bien été désinscrit.</p>"
|
|
else
|
|
@message = "Votre adresse mail ne figure pas dans notre fichier."
|
|
end
|
|
end
|
|
|
|
def email_validation
|
|
@registrant = Registrant.find_by_token(params[:id])
|
|
if @registrant
|
|
@registrant.enabled = true
|
|
@registrant.save
|
|
@message = "<p>Merci, votre inscription a bien été prise en compte.</p> "
|
|
else
|
|
@message = "Votre adresse mail ne figure pas dans le fichier."
|
|
end
|
|
end
|
|
|
|
|
|
end
|