admin: alias Administrateur.email
This commit is contained in:
parent
7bb298722f
commit
2bb161c3cb
3 changed files with 7 additions and 5 deletions
|
@ -1,6 +1,5 @@
|
|||
class Administrateur < ApplicationRecord
|
||||
self.ignored_columns = ['features', 'encrypted_password', 'reset_password_token', 'reset_password_sent_at', 'remember_created_at', 'sign_in_count', 'current_sign_in_at', 'last_sign_in_at', 'current_sign_in_ip', 'last_sign_in_ip', 'failed_attempts', 'unlock_token', 'locked_at']
|
||||
include EmailSanitizableConcern
|
||||
include ActiveRecord::SecureToken
|
||||
|
||||
has_and_belongs_to_many :instructeurs
|
||||
|
@ -10,14 +9,17 @@ class Administrateur < ApplicationRecord
|
|||
|
||||
has_one :user, dependent: :nullify
|
||||
|
||||
before_validation -> { sanitize_email(:email) }
|
||||
|
||||
scope :inactive, -> { joins(:user).where(users: { last_sign_in_at: nil }) }
|
||||
scope :with_publiees_ou_closes, -> { joins(:procedures).where(procedures: { aasm_state: [:publiee, :close, :depubliee] }) }
|
||||
|
||||
def self.by_email(email)
|
||||
Administrateur.eager_load(:user).find_by(users: { email: email })
|
||||
end
|
||||
|
||||
def email
|
||||
user.email
|
||||
end
|
||||
|
||||
# validate :password_complexity, if: Proc.new { |a| Devise.password_length.include?(a.password.try(:size)) }
|
||||
|
||||
def password_complexity
|
||||
|
|
|
@ -381,7 +381,7 @@ class Dossier < ApplicationRecord
|
|||
update(hidden_at: deleted_dossier.deleted_at)
|
||||
|
||||
if en_construction?
|
||||
administration_emails = followers_instructeurs.present? ? followers_instructeurs.map(&:email) : procedure.administrateurs.pluck(:email)
|
||||
administration_emails = followers_instructeurs.present? ? followers_instructeurs.map(&:email) : procedure.administrateurs.map(&:email)
|
||||
administration_emails.each do |email|
|
||||
DossierMailer.notify_deletion_to_administration(deleted_dossier, email).deliver_later
|
||||
end
|
||||
|
|
|
@ -56,4 +56,4 @@
|
|||
%td.flex
|
||||
= link_to('Consulter', apercu_procedure_path(id: procedure.id), target: "_blank", rel: "noopener", class: 'button small')
|
||||
= link_to('Cloner', admin_procedure_clone_path(procedure.id, from_new_from_existing: true), 'data-method' => :put, class: 'button small primary')
|
||||
= link_to('Contacter', "mailto:#{procedure.administrateurs.pluck(:email) * ","}", class: 'button small')
|
||||
= link_to('Contacter', "mailto:#{procedure.administrateurs.map(&:email) * ","}", class: 'button small')
|
||||
|
|
Loading…
Add table
Reference in a new issue