2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-08-11 10:49:16 +02:00
|
|
|
class ContactInformation < ApplicationRecord
|
2024-02-15 09:45:20 +01:00
|
|
|
include EmailSanitizableConcern
|
|
|
|
|
2023-08-11 10:49:16 +02:00
|
|
|
belongs_to :groupe_instructeur
|
|
|
|
|
|
|
|
validates :nom, presence: { message: 'doit être renseigné' }, allow_nil: false
|
|
|
|
validates :nom, uniqueness: { scope: :groupe_instructeur, message: 'existe déjà' }
|
2024-02-13 10:37:03 +01:00
|
|
|
validates :email, strict_email: true, presence: { message: 'doit être renseigné' }, allow_nil: false
|
2023-08-11 10:49:16 +02:00
|
|
|
validates :telephone, phone: { possible: true, allow_blank: false }
|
|
|
|
validates :horaires, presence: { message: 'doivent être renseignés' }, allow_nil: false
|
|
|
|
validates :adresse, presence: { message: 'doit être renseignée' }, allow_nil: false
|
|
|
|
validates :groupe_instructeur, presence: { message: 'doit être renseigné' }, allow_nil: false
|
2024-02-15 09:45:20 +01:00
|
|
|
before_validation -> { sanitize_email(:email) }
|
2023-08-14 17:43:35 +02:00
|
|
|
|
2023-09-27 12:09:00 +02:00
|
|
|
def pretty_nom
|
|
|
|
nom
|
|
|
|
end
|
|
|
|
|
2023-08-14 17:43:35 +02:00
|
|
|
def telephone_url
|
|
|
|
if telephone.present?
|
|
|
|
"tel:#{telephone.gsub(/[[:blank:]]/, '')}"
|
|
|
|
end
|
|
|
|
end
|
2024-03-05 14:50:52 +01:00
|
|
|
|
|
|
|
def organisme
|
|
|
|
end
|
2023-08-11 10:49:16 +02:00
|
|
|
end
|