Models
This commit is contained in:
parent
061da95aaf
commit
2ac9c13c4a
2 changed files with 18 additions and 5 deletions
|
@ -447,6 +447,9 @@ class Dossier < ApplicationRecord
|
||||||
|
|
||||||
validates :user, presence: true, if: -> { deleted_user_email_never_send.nil? }, unless: -> { prefilled }
|
validates :user, presence: true, if: -> { deleted_user_email_never_send.nil? }, unless: -> { prefilled }
|
||||||
validates :individual, presence: true, if: -> { revision.procedure.for_individual? }
|
validates :individual, presence: true, if: -> { revision.procedure.for_individual? }
|
||||||
|
validates :mandataire_first_name, presence: true, if: :for_tiers?
|
||||||
|
validates :mandataire_last_name, presence: true, if: :for_tiers?
|
||||||
|
validates :for_tiers, inclusion: { in: [true, false] }, if: -> { revision&.procedure&.for_individual? }
|
||||||
|
|
||||||
validates_associated :prefilled_champs_public, on: :champs_public_value
|
validates_associated :prefilled_champs_public, on: :champs_public_value
|
||||||
|
|
||||||
|
@ -1366,6 +1369,10 @@ class Dossier < ApplicationRecord
|
||||||
groupe_instructeur&.contact_information || procedure.service
|
groupe_instructeur&.contact_information || procedure.service
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mandataire_full_name
|
||||||
|
"#{mandataire_first_name} #{mandataire_last_name}"
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def create_missing_traitemets
|
def create_missing_traitemets
|
||||||
|
|
|
@ -1,19 +1,25 @@
|
||||||
class Individual < ApplicationRecord
|
class Individual < ApplicationRecord
|
||||||
|
enum notification_method: {
|
||||||
|
email: 'email',
|
||||||
|
no_notification: 'no_notification'
|
||||||
|
}
|
||||||
|
|
||||||
belongs_to :dossier, optional: false
|
belongs_to :dossier, optional: false
|
||||||
|
|
||||||
validates :dossier_id, uniqueness: true
|
validates :dossier_id, uniqueness: true
|
||||||
validates :gender, presence: true, allow_nil: false, on: :update
|
validates :gender, presence: true, allow_nil: false, on: :update
|
||||||
validates :nom, presence: true, allow_blank: false, allow_nil: false, on: :update
|
validates :nom, presence: true, allow_blank: false, allow_nil: false, on: :update
|
||||||
validates :prenom, presence: true, allow_blank: false, allow_nil: false, on: :update
|
validates :prenom, presence: true, allow_blank: false, allow_nil: false, on: :update
|
||||||
|
validates :notification_method, presence: true,
|
||||||
|
inclusion: { in: notification_methods.keys },
|
||||||
|
if: -> { dossier.for_tiers? },
|
||||||
|
on: :update
|
||||||
|
|
||||||
|
validates :email, presence: true, if: -> { dossier.for_tiers? && self.email? }, on: :update
|
||||||
|
|
||||||
GENDER_MALE = "M."
|
GENDER_MALE = "M."
|
||||||
GENDER_FEMALE = 'Mme'
|
GENDER_FEMALE = 'Mme'
|
||||||
|
|
||||||
enum notification_method: {
|
|
||||||
email: 'email',
|
|
||||||
no_notification: 'no_notification'
|
|
||||||
}
|
|
||||||
|
|
||||||
def self.from_france_connect(fc_information)
|
def self.from_france_connect(fc_information)
|
||||||
new(
|
new(
|
||||||
nom: fc_information.family_name,
|
nom: fc_information.family_name,
|
||||||
|
|
Loading…
Add table
Reference in a new issue