feat: US4.3.8 administrateur management
This commit is contained in:
parent
51c5a8d0f7
commit
564c3c04fa
33 changed files with 449 additions and 76 deletions
|
@ -1,4 +1,5 @@
|
|||
class Instructeur < ApplicationRecord
|
||||
include UserFindByConcern
|
||||
has_and_belongs_to_many :administrateurs
|
||||
|
||||
has_many :assign_to, dependent: :destroy
|
||||
|
@ -36,24 +37,6 @@ class Instructeur < ApplicationRecord
|
|||
|
||||
default_scope { eager_load(:user) }
|
||||
|
||||
def self.by_email(email)
|
||||
find_by(users: { email: email })
|
||||
end
|
||||
|
||||
def self.find_all_by_identifier(ids: [], emails: [])
|
||||
find_all_by_identifier_with_emails(ids:, emails:).first
|
||||
end
|
||||
|
||||
def self.find_all_by_identifier_with_emails(ids: [], emails: [])
|
||||
valid_emails, invalid_emails = emails.partition { URI::MailTo::EMAIL_REGEXP.match?(_1) }
|
||||
|
||||
[
|
||||
where(id: ids).or(where(users: { email: valid_emails })).distinct(:id),
|
||||
valid_emails,
|
||||
invalid_emails
|
||||
]
|
||||
end
|
||||
|
||||
def email
|
||||
user.email
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue