feat: rename admins_group_manager to gestionnaire
This commit is contained in:
parent
e9f2b56866
commit
44b4b5d0ab
60 changed files with 310 additions and 310 deletions
|
@ -1,9 +0,0 @@
|
||||||
module AdminsGroupManagers
|
|
||||||
class AdminsGroupManagerController < ApplicationController
|
|
||||||
before_action :authenticate_admins_group_manager!
|
|
||||||
|
|
||||||
def nav_bar_profile
|
|
||||||
:admins_group_manager
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,14 +0,0 @@
|
||||||
module AdminsGroupManagers
|
|
||||||
class AdminsGroupsController < AdminsGroupManagerController
|
|
||||||
def index
|
|
||||||
@admins_groups = admins_groups
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def admins_groups
|
|
||||||
admins_group_ids = current_admins_group_manager.admins_group_ids
|
|
||||||
AdminsGroup.where(id: admins_group_ids.compact.uniq)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -22,7 +22,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
helper_method :multiple_devise_profile_connect?, :instructeur_signed_in?, :current_instructeur, :current_expert, :expert_signed_in?,
|
helper_method :multiple_devise_profile_connect?, :instructeur_signed_in?, :current_instructeur, :current_expert, :expert_signed_in?,
|
||||||
:administrateur_signed_in?, :current_administrateur, :current_account, :localization_enabled?, :set_locale, :current_expert_not_instructeur?,
|
:administrateur_signed_in?, :current_administrateur, :current_account, :localization_enabled?, :set_locale, :current_expert_not_instructeur?,
|
||||||
:admins_group_manager_signed_in?, :current_admins_group_manager
|
:gestionnaire_signed_in?, :current_gestionnaire
|
||||||
|
|
||||||
before_action do
|
before_action do
|
||||||
Current.request_id = request.uuid
|
Current.request_id = request.uuid
|
||||||
|
@ -38,12 +38,12 @@ class ApplicationController < ActionController::Base
|
||||||
def multiple_devise_profile_connect?
|
def multiple_devise_profile_connect?
|
||||||
user_signed_in? && instructeur_signed_in? ||
|
user_signed_in? && instructeur_signed_in? ||
|
||||||
instructeur_signed_in? && administrateur_signed_in? ||
|
instructeur_signed_in? && administrateur_signed_in? ||
|
||||||
instructeur_signed_in? && admins_group_manager_signed_in? ||
|
instructeur_signed_in? && gestionnaire_signed_in? ||
|
||||||
instructeur_signed_in? && expert_signed_in? ||
|
instructeur_signed_in? && expert_signed_in? ||
|
||||||
user_signed_in? && administrateur_signed_in? ||
|
user_signed_in? && administrateur_signed_in? ||
|
||||||
user_signed_in? && admins_group_manager_signed_in? ||
|
user_signed_in? && gestionnaire_signed_in? ||
|
||||||
user_signed_in? && expert_signed_in? ||
|
user_signed_in? && expert_signed_in? ||
|
||||||
administrateur_signed_in? && admins_group_manager_signed_in?
|
administrateur_signed_in? && gestionnaire_signed_in?
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_instructeur
|
def current_instructeur
|
||||||
|
@ -62,12 +62,12 @@ class ApplicationController < ActionController::Base
|
||||||
current_administrateur.present?
|
current_administrateur.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_admins_group_manager
|
def current_gestionnaire
|
||||||
current_user&.admins_group_manager
|
current_user&.gestionnaire
|
||||||
end
|
end
|
||||||
|
|
||||||
def admins_group_manager_signed_in?
|
def gestionnaire_signed_in?
|
||||||
current_admins_group_manager.present?
|
current_gestionnaire.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_expert
|
def current_expert
|
||||||
|
@ -84,7 +84,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def current_account
|
def current_account
|
||||||
{
|
{
|
||||||
admins_group_manager: current_admins_group_manager,
|
gestionnaire: current_gestionnaire,
|
||||||
administrateur: current_administrateur,
|
administrateur: current_administrateur,
|
||||||
instructeur: current_instructeur,
|
instructeur: current_instructeur,
|
||||||
user: current_user
|
user: current_user
|
||||||
|
@ -128,8 +128,8 @@ class ApplicationController < ActionController::Base
|
||||||
authenticate_expert!
|
authenticate_expert!
|
||||||
elsif administrateur_signed_in?
|
elsif administrateur_signed_in?
|
||||||
authenticate_administrateur!
|
authenticate_administrateur!
|
||||||
elsif admins_group_manager_signed_in?
|
elsif gestionnaire_signed_in?
|
||||||
authenticate_admins_group_manager!
|
authenticate_gestionnaire!
|
||||||
else
|
else
|
||||||
authenticate_user!
|
authenticate_user!
|
||||||
end
|
end
|
||||||
|
@ -159,8 +159,8 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_admins_group_manager!
|
def authenticate_gestionnaire!
|
||||||
if !admins_group_manager_signed_in?
|
if !gestionnaire_signed_in?
|
||||||
redirect_to new_user_session_path
|
redirect_to new_user_session_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -199,7 +199,7 @@ class ApplicationController < ActionController::Base
|
||||||
current_user,
|
current_user,
|
||||||
current_instructeur,
|
current_instructeur,
|
||||||
current_administrateur,
|
current_administrateur,
|
||||||
current_admins_group_manager,
|
current_gestionnaire,
|
||||||
current_super_admin
|
current_super_admin
|
||||||
].compact.map { |role| role.class.name }
|
].compact.map { |role| role.class.name }
|
||||||
|
|
||||||
|
|
9
app/controllers/gestionnaires/gestionnaire_controller.rb
Normal file
9
app/controllers/gestionnaires/gestionnaire_controller.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
module Gestionnaires
|
||||||
|
class GestionnaireController < ApplicationController
|
||||||
|
before_action :authenticate_gestionnaire!
|
||||||
|
|
||||||
|
def nav_bar_profile
|
||||||
|
:gestionnaire
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,14 @@
|
||||||
|
module Gestionnaires
|
||||||
|
class GroupeGestionnairesController < GestionnaireController
|
||||||
|
def index
|
||||||
|
@groupe_gestionnaires = groupe_gestionnaires
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def groupe_gestionnaires
|
||||||
|
groupe_gestionnaire_ids = current_gestionnaire.groupe_gestionnaire_ids
|
||||||
|
GroupeGestionnaire.where(id: groupe_gestionnaire_ids.compact.uniq)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,4 +0,0 @@
|
||||||
module Manager
|
|
||||||
class AdminsGroupManagersController < Manager::ApplicationController
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,32 +0,0 @@
|
||||||
module Manager
|
|
||||||
class AdminsGroupsController < Manager::ApplicationController
|
|
||||||
def add_admins_group_manager
|
|
||||||
emails = (params['emails'].presence || '').split(',').to_json
|
|
||||||
emails = JSON.parse(emails).map { EmailSanitizableConcern::EmailSanitizer.sanitize(_1) }
|
|
||||||
|
|
||||||
admins_group_managers, invalid_emails = admins_group.add_admins_group_managers(emails:)
|
|
||||||
|
|
||||||
if invalid_emails.present?
|
|
||||||
flash[:alert] = t('.wrong_address',
|
|
||||||
count: invalid_emails.size,
|
|
||||||
emails: invalid_emails)
|
|
||||||
end
|
|
||||||
|
|
||||||
if admins_group_managers.present?
|
|
||||||
flash[:notice] = "Les gestionnaires ont bien été affectés au groupe d'administrateurs"
|
|
||||||
|
|
||||||
AdminsGroupMailer
|
|
||||||
.notify_added_admins_group_managers(admins_group, admins_group_managers, current_super_admin.email)
|
|
||||||
.deliver_later
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to manager_admins_groups_path(admins_group)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def admins_group
|
|
||||||
@admins_group ||= AdminsGroup.find(params[:id])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
4
app/controllers/manager/gestionnaires_controller.rb
Normal file
4
app/controllers/manager/gestionnaires_controller.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
module Manager
|
||||||
|
class GestionnairesController < Manager::ApplicationController
|
||||||
|
end
|
||||||
|
end
|
32
app/controllers/manager/groupe_gestionnaires_controller.rb
Normal file
32
app/controllers/manager/groupe_gestionnaires_controller.rb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
module Manager
|
||||||
|
class GroupeGestionnairesController < Manager::ApplicationController
|
||||||
|
def add_gestionnaire
|
||||||
|
emails = (params['emails'].presence || '').split(',').to_json
|
||||||
|
emails = JSON.parse(emails).map { EmailSanitizableConcern::EmailSanitizer.sanitize(_1) }
|
||||||
|
|
||||||
|
gestionnaires, invalid_emails = groupe_gestionnaire.add_gestionnaires(emails:)
|
||||||
|
|
||||||
|
if invalid_emails.present?
|
||||||
|
flash[:alert] = t('.wrong_address',
|
||||||
|
count: invalid_emails.size,
|
||||||
|
emails: invalid_emails)
|
||||||
|
end
|
||||||
|
|
||||||
|
if gestionnaires.present?
|
||||||
|
flash[:notice] = "Les gestionnaires ont bien été affectés au groupe d'administrateurs"
|
||||||
|
|
||||||
|
GroupeGestionnaireMailer
|
||||||
|
.notify_added_gestionnaires(groupe_gestionnaire, gestionnaires, current_super_admin.email)
|
||||||
|
.deliver_later
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to manager_groupe_gestionnaires_path(groupe_gestionnaire)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def groupe_gestionnaire
|
||||||
|
@groupe_gestionnaire ||= GroupeGestionnaire.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
require "administrate/base_dashboard"
|
require "administrate/base_dashboard"
|
||||||
|
|
||||||
class AdminsGroupManagerDashboard < Administrate::BaseDashboard
|
class GestionnaireDashboard < Administrate::BaseDashboard
|
||||||
# ATTRIBUTE_TYPES
|
# ATTRIBUTE_TYPES
|
||||||
# a hash that describes the type of each of the model's fields.
|
# a hash that describes the type of each of the model's fields.
|
||||||
#
|
#
|
||||||
|
@ -12,7 +12,7 @@ class AdminsGroupManagerDashboard < Administrate::BaseDashboard
|
||||||
user: Field::HasOne.with_options(searchable: true, searchable_field: 'email'),
|
user: Field::HasOne.with_options(searchable: true, searchable_field: 'email'),
|
||||||
created_at: Field::DateTime,
|
created_at: Field::DateTime,
|
||||||
updated_at: Field::DateTime,
|
updated_at: Field::DateTime,
|
||||||
admins_groups: Field::HasMany.with_options(limit: 20),
|
groupe_gestionnaires: Field::HasMany.with_options(limit: 20),
|
||||||
registration_state: Field::String.with_options(searchable: false),
|
registration_state: Field::String.with_options(searchable: false),
|
||||||
email: Field::Email.with_options(searchable: false)
|
email: Field::Email.with_options(searchable: false)
|
||||||
}.freeze
|
}.freeze
|
||||||
|
@ -26,7 +26,7 @@ class AdminsGroupManagerDashboard < Administrate::BaseDashboard
|
||||||
:id,
|
:id,
|
||||||
:user,
|
:user,
|
||||||
:created_at,
|
:created_at,
|
||||||
:admins_groups,
|
:groupe_gestionnaires,
|
||||||
:registration_state
|
:registration_state
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class AdminsGroupManagerDashboard < Administrate::BaseDashboard
|
||||||
:created_at,
|
:created_at,
|
||||||
:updated_at,
|
:updated_at,
|
||||||
:registration_state,
|
:registration_state,
|
||||||
:admins_groups
|
:groupe_gestionnaires
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
# FORM_ATTRIBUTES
|
# FORM_ATTRIBUTES
|
||||||
|
@ -51,7 +51,7 @@ class AdminsGroupManagerDashboard < Administrate::BaseDashboard
|
||||||
# Overwrite this method to customize how users are displayed
|
# Overwrite this method to customize how users are displayed
|
||||||
# across all pages of the admin dashboard.
|
# across all pages of the admin dashboard.
|
||||||
#
|
#
|
||||||
def display_resource(admins_group_manager)
|
def display_resource(gestionnaire)
|
||||||
admins_group_manager.email
|
gestionnaire.email
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
require "administrate/base_dashboard"
|
require "administrate/base_dashboard"
|
||||||
|
|
||||||
class AdminsGroupDashboard < Administrate::BaseDashboard
|
class GroupeGestionnaireDashboard < Administrate::BaseDashboard
|
||||||
# ATTRIBUTE_TYPES
|
# ATTRIBUTE_TYPES
|
||||||
# a hash that describes the type of each of the model's fields.
|
# a hash that describes the type of each of the model's fields.
|
||||||
#
|
#
|
||||||
|
@ -12,7 +12,7 @@ class AdminsGroupDashboard < Administrate::BaseDashboard
|
||||||
name: Field::String,
|
name: Field::String,
|
||||||
created_at: Field::DateTime,
|
created_at: Field::DateTime,
|
||||||
updated_at: Field::DateTime,
|
updated_at: Field::DateTime,
|
||||||
admins_group_managers: Field::HasMany,
|
gestionnaires: Field::HasMany,
|
||||||
administrateurs: Field::HasMany
|
administrateurs: Field::HasMany
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
@ -25,14 +25,14 @@ class AdminsGroupDashboard < Administrate::BaseDashboard
|
||||||
:id,
|
:id,
|
||||||
:created_at,
|
:created_at,
|
||||||
:name,
|
:name,
|
||||||
:admins_group_managers,
|
:gestionnaires,
|
||||||
:administrateurs
|
:administrateurs
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
# SHOW_PAGE_ATTRIBUTES
|
# SHOW_PAGE_ATTRIBUTES
|
||||||
# an array of attributes that will be displayed on the model's show page.
|
# an array of attributes that will be displayed on the model's show page.
|
||||||
SHOW_PAGE_ATTRIBUTES = [
|
SHOW_PAGE_ATTRIBUTES = [
|
||||||
:admins_group_managers,
|
:gestionnaires,
|
||||||
:administrateurs,
|
:administrateurs,
|
||||||
:id,
|
:id,
|
||||||
:created_at
|
:created_at
|
||||||
|
@ -48,7 +48,7 @@ class AdminsGroupDashboard < Administrate::BaseDashboard
|
||||||
# Overwrite this method to customize how users are displayed
|
# Overwrite this method to customize how users are displayed
|
||||||
# across all pages of the admin dashboard.
|
# across all pages of the admin dashboard.
|
||||||
#
|
#
|
||||||
def display_resource(admins_group)
|
def display_resource(groupe_gestionnaire)
|
||||||
admins_group.name
|
groupe_gestionnaire.name
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -48,7 +48,7 @@ module ApplicationHelper
|
||||||
current_user&.email ||
|
current_user&.email ||
|
||||||
current_instructeur&.email ||
|
current_instructeur&.email ||
|
||||||
current_administrateur&.email ||
|
current_administrateur&.email ||
|
||||||
current_admins_group_manager&.email
|
current_gestionnaire&.email
|
||||||
end
|
end
|
||||||
|
|
||||||
def staging?
|
def staging?
|
||||||
|
@ -78,8 +78,8 @@ module ApplicationHelper
|
||||||
case nav_bar_profile
|
case nav_bar_profile
|
||||||
when :administrateur
|
when :administrateur
|
||||||
[admin_procedures_path, t("admin", scope: "layouts.root_path_link_title")]
|
[admin_procedures_path, t("admin", scope: "layouts.root_path_link_title")]
|
||||||
when :admins_group_manager
|
when :gestionnaire
|
||||||
[admins_group_manager_admins_groups_path, t("admins_group_manager", scope: "layouts.root_path_link_title")]
|
[gestionnaire_groupe_gestionnaires_path, t("gestionnaire", scope: "layouts.root_path_link_title")]
|
||||||
when :instructeur
|
when :instructeur
|
||||||
[instructeur_procedures_path, t("instructeur", scope: "layouts.root_path_link_title")]
|
[instructeur_procedures_path, t("instructeur", scope: "layouts.root_path_link_title")]
|
||||||
when :user
|
when :user
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
class AdminsGroupMailer < ApplicationMailer
|
|
||||||
layout 'mailers/layout'
|
|
||||||
|
|
||||||
def notify_added_admins_group_managers(admins_group, added_admins_group_managers, current_super_admin_email)
|
|
||||||
added_admins_group_manager_emails = added_admins_group_managers.map(&:email)
|
|
||||||
@admins_group = admins_group
|
|
||||||
@current_super_admin_email = current_super_admin_email
|
|
||||||
|
|
||||||
subject = "Vous avez été ajouté(e) en tant que gestionnaire du groupe d'administrateur \"#{admins_group.name}\""
|
|
||||||
|
|
||||||
mail(bcc: added_admins_group_manager_emails, subject: subject)
|
|
||||||
end
|
|
||||||
end
|
|
13
app/mailers/groupe_gestionnaire_mailer.rb
Normal file
13
app/mailers/groupe_gestionnaire_mailer.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
class GroupeGestionnaireMailer < ApplicationMailer
|
||||||
|
layout 'mailers/layout'
|
||||||
|
|
||||||
|
def notify_added_gestionnaires(groupe_gestionnaire, added_gestionnaires, current_super_admin_email)
|
||||||
|
added_gestionnaire_emails = added_gestionnaires.map(&:email)
|
||||||
|
@groupe_gestionnaire = groupe_gestionnaire
|
||||||
|
@current_super_admin_email = current_super_admin_email
|
||||||
|
|
||||||
|
subject = "Vous avez été ajouté(e) en tant que gestionnaire du groupe d'administrateur \"#{groupe_gestionnaire.name}\""
|
||||||
|
|
||||||
|
mail(bcc: added_gestionnaire_emails, subject: subject)
|
||||||
|
end
|
||||||
|
end
|
|
@ -38,10 +38,10 @@ class UserMailer < ApplicationMailer
|
||||||
reply_to: CONTACT_EMAIL)
|
reply_to: CONTACT_EMAIL)
|
||||||
end
|
end
|
||||||
|
|
||||||
def invite_admins_group_manager(user, reset_password_token, admins_group)
|
def invite_gestionnaire(user, reset_password_token, groupe_gestionnaire)
|
||||||
@reset_password_token = reset_password_token
|
@reset_password_token = reset_password_token
|
||||||
@user = user
|
@user = user
|
||||||
@admins_group = admins_group
|
@groupe_gestionnaire = groupe_gestionnaire
|
||||||
subject = "Activez votre compte gestionnaire"
|
subject = "Activez votre compte gestionnaire"
|
||||||
|
|
||||||
mail(to: user.email,
|
mail(to: user.email,
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Administrateur < ApplicationRecord
|
||||||
has_and_belongs_to_many :default_zones, class_name: 'Zone', join_table: 'default_zones_administrateurs'
|
has_and_belongs_to_many :default_zones, class_name: 'Zone', join_table: 'default_zones_administrateurs'
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :admins_group, optional: true
|
belongs_to :groupe_gestionnaire, optional: true
|
||||||
|
|
||||||
default_scope { eager_load(:user) }
|
default_scope { eager_load(:user) }
|
||||||
|
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
class AdminsGroup < ApplicationRecord
|
|
||||||
belongs_to :admins_group, optional: true # parent
|
|
||||||
has_many :children, class_name: "AdminsGroup", inverse_of: :admins_group
|
|
||||||
has_many :administrateurs
|
|
||||||
has_and_belongs_to_many :admins_group_managers
|
|
||||||
|
|
||||||
def add(admins_group_manager)
|
|
||||||
admins_group_managers << admins_group_manager
|
|
||||||
end
|
|
||||||
|
|
||||||
def add_admins_group_managers(ids: [], emails: [])
|
|
||||||
admins_group_managers_to_add, valid_emails, invalid_emails = AdminsGroupManager.find_all_by_identifier_with_emails(ids:, emails:)
|
|
||||||
not_found_emails = valid_emails - admins_group_managers_to_add.map(&:email)
|
|
||||||
|
|
||||||
# Send invitations to users without account
|
|
||||||
if not_found_emails.present?
|
|
||||||
admins_group_managers_to_add += not_found_emails.map do |email|
|
|
||||||
user = User.create_or_promote_to_admins_group_manager(email, SecureRandom.hex)
|
|
||||||
user.invite_admins_group_manager!(self)
|
|
||||||
user.admins_group_manager
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# We dont't want to assign a user to an admins_group if they are already assigned to it
|
|
||||||
admins_group_managers_to_add -= admins_group_managers
|
|
||||||
admins_group_managers_to_add.each { add(_1) }
|
|
||||||
|
|
||||||
[admins_group_managers_to_add, invalid_emails]
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +1,5 @@
|
||||||
class AdminsGroupManager < ApplicationRecord
|
class Gestionnaire < ApplicationRecord
|
||||||
has_and_belongs_to_many :admins_groups
|
has_and_belongs_to_many :groupe_gestionnaires
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class AdminsGroupManager < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_be_deleted?
|
def can_be_deleted?
|
||||||
!(root_admins_group = admins_groups.where(admins_group: nil).first) || root_admins_group.admins_group_managers.size > 1
|
!(root_groupe_gestionnaire = groupe_gestionnaires.where(groupe_gestionnaire: nil).first) || root_groupe_gestionnaire.gestionnaires.size > 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def registration_state
|
def registration_state
|
30
app/models/groupe_gestionnaire.rb
Normal file
30
app/models/groupe_gestionnaire.rb
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
class GroupeGestionnaire < ApplicationRecord
|
||||||
|
belongs_to :groupe_gestionnaire, optional: true # parent
|
||||||
|
has_many :children, class_name: "GroupeGestionnaire", inverse_of: :groupe_gestionnaire
|
||||||
|
has_many :administrateurs
|
||||||
|
has_and_belongs_to_many :gestionnaires
|
||||||
|
|
||||||
|
def add(gestionnaire)
|
||||||
|
gestionnaires << gestionnaire
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_gestionnaires(ids: [], emails: [])
|
||||||
|
gestionnaires_to_add, valid_emails, invalid_emails = Gestionnaire.find_all_by_identifier_with_emails(ids:, emails:)
|
||||||
|
not_found_emails = valid_emails - gestionnaires_to_add.map(&:email)
|
||||||
|
|
||||||
|
# Send invitations to users without account
|
||||||
|
if not_found_emails.present?
|
||||||
|
gestionnaires_to_add += not_found_emails.map do |email|
|
||||||
|
user = User.create_or_promote_to_gestionnaire(email, SecureRandom.hex)
|
||||||
|
user.invite_gestionnaire!(self)
|
||||||
|
user.gestionnaire
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# We dont't want to assign a user to an groupe_gestionnaire if they are already assigned to it
|
||||||
|
gestionnaires_to_add -= gestionnaires
|
||||||
|
gestionnaires_to_add.each { add(_1) }
|
||||||
|
|
||||||
|
[gestionnaires_to_add, invalid_emails]
|
||||||
|
end
|
||||||
|
end
|
|
@ -26,7 +26,7 @@ class User < ApplicationRecord
|
||||||
has_one :france_connect_information, dependent: :destroy
|
has_one :france_connect_information, dependent: :destroy
|
||||||
has_one :instructeur, dependent: :destroy
|
has_one :instructeur, dependent: :destroy
|
||||||
has_one :administrateur, dependent: :destroy
|
has_one :administrateur, dependent: :destroy
|
||||||
has_one :admins_group_manager, dependent: :destroy
|
has_one :gestionnaire, dependent: :destroy
|
||||||
has_one :expert, dependent: :destroy
|
has_one :expert, dependent: :destroy
|
||||||
belongs_to :requested_merge_into, class_name: 'User', optional: true
|
belongs_to :requested_merge_into, class_name: 'User', optional: true
|
||||||
|
|
||||||
|
@ -77,8 +77,8 @@ class User < ApplicationRecord
|
||||||
UserMailer.invite_instructeur(self, set_reset_password_token).deliver_later
|
UserMailer.invite_instructeur(self, set_reset_password_token).deliver_later
|
||||||
end
|
end
|
||||||
|
|
||||||
def invite_admins_group_manager!(admins_group)
|
def invite_gestionnaire!(groupe_gestionnaire)
|
||||||
UserMailer.invite_admins_group_manager(self, set_reset_password_token, admins_group).deliver_later
|
UserMailer.invite_gestionnaire(self, set_reset_password_token, groupe_gestionnaire).deliver_later
|
||||||
end
|
end
|
||||||
|
|
||||||
def invite_administrateur!(administration_id)
|
def invite_administrateur!(administration_id)
|
||||||
|
@ -108,11 +108,11 @@ class User < ApplicationRecord
|
||||||
user
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_or_promote_to_admins_group_manager(email, password)
|
def self.create_or_promote_to_gestionnaire(email, password)
|
||||||
user = User.create_or_promote_to_administrateur(email, password)
|
user = User.create_or_promote_to_administrateur(email, password)
|
||||||
|
|
||||||
if user.valid? && user.admins_group_manager.nil?
|
if user.valid? && user.gestionnaire.nil?
|
||||||
user.create_admins_group_manager!
|
user.create_gestionnaire!
|
||||||
end
|
end
|
||||||
|
|
||||||
user
|
user
|
||||||
|
@ -160,8 +160,8 @@ class User < ApplicationRecord
|
||||||
instructeur.present?
|
instructeur.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def admins_group_manager?
|
def gestionnaire?
|
||||||
admins_group_manager.present?
|
gestionnaire.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def expert?
|
def expert?
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
%p= t(:hello, scope: [:views, :shared, :greetings])
|
|
||||||
|
|
||||||
%p
|
|
||||||
= t(".email_body", admins_group_name: @admins_group.name, email: @current_super_admin_email, application_name: APPLICATION_NAME)
|
|
||||||
|
|
||||||
= render partial: "layouts/mailers/signature"
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
%p= t(:hello, scope: [:views, :shared, :greetings])
|
||||||
|
|
||||||
|
%p
|
||||||
|
= t(".email_body", groupe_gestionnaire_name: @groupe_gestionnaire.name, email: @current_super_admin_email, application_name: APPLICATION_NAME)
|
||||||
|
|
||||||
|
= render partial: "layouts/mailers/signature"
|
|
@ -30,11 +30,11 @@
|
||||||
= link_to admin_procedures_path, class: "fr-nav__link" do
|
= link_to admin_procedures_path, class: "fr-nav__link" do
|
||||||
%span.fr-icon-refresh-line.fr-icon--sm
|
%span.fr-icon-refresh-line.fr-icon--sm
|
||||||
= t('go_admin', scope: [:layouts])
|
= t('go_admin', scope: [:layouts])
|
||||||
- if admins_group_manager_signed_in? && nav_bar_profile != :admins_group_manager
|
- if gestionnaire_signed_in? && nav_bar_profile != :gestionnaire
|
||||||
%li
|
%li
|
||||||
= link_to admins_group_manager_admins_groups_path, class: "fr-nav__link" do
|
= link_to gestionnaire_groupe_gestionnaires_path, class: "fr-nav__link" do
|
||||||
%span.fr-icon-refresh-line.fr-icon--sm
|
%span.fr-icon-refresh-line.fr-icon--sm
|
||||||
= t('go_admins_group_manager', scope: [:layouts])
|
= t('go_gestionnaire', scope: [:layouts])
|
||||||
|
|
||||||
- if super_admin_signed_in?
|
- if super_admin_signed_in?
|
||||||
%li
|
%li
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Bonjour,
|
Bonjour,
|
||||||
|
|
||||||
%p
|
%p
|
||||||
Vous venez d’être nommé gestionnaire du groupe #{@admins_group.name} sur #{APPLICATION_NAME}.
|
Vous venez d’être nommé gestionnaire du groupe #{@groupe_gestionnaire.name} sur #{APPLICATION_NAME}.
|
||||||
|
|
||||||
%p
|
%p
|
||||||
Votre compte a été créé pour l'adresse email #{@user.email}. Pour l’activer, nous vous invitons à cliquer sur le lien suivant :
|
Votre compte a été créé pour l'adresse email #{@user.email}. Pour l’activer, nous vous invitons à cliquer sur le lien suivant :
|
|
@ -101,7 +101,7 @@ en:
|
||||||
user: 'Go to files list'
|
user: 'Go to files list'
|
||||||
instructeur: 'Go to procedures list'
|
instructeur: 'Go to procedures list'
|
||||||
admin: 'Go to administration panel'
|
admin: 'Go to administration panel'
|
||||||
admins_group_manager: "Aller admins group panel"
|
gestionnaire: "Aller admins group panel"
|
||||||
views:
|
views:
|
||||||
legal_notice:
|
legal_notice:
|
||||||
title: "Legal Notices"
|
title: "Legal Notices"
|
||||||
|
|
|
@ -92,7 +92,7 @@ fr:
|
||||||
user: 'Aller à la liste des dossiers'
|
user: 'Aller à la liste des dossiers'
|
||||||
instructeur: 'Aller à la liste des démarches'
|
instructeur: 'Aller à la liste des démarches'
|
||||||
admin: "Aller au panneau d’administration"
|
admin: "Aller au panneau d’administration"
|
||||||
admins_group_manager: "Aller au panneau de gestionnaire"
|
gestionnaire: "Aller au panneau de gestionnaire"
|
||||||
views:
|
views:
|
||||||
legal_notice:
|
legal_notice:
|
||||||
title: "Mentions légales"
|
title: "Mentions légales"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
fr:
|
fr:
|
||||||
activerecord:
|
activerecord:
|
||||||
attributes:
|
attributes:
|
||||||
admins_group_manager:
|
gestionnaire:
|
||||||
admins_groups: Groupes
|
groupe_gestionnaires: Groupes
|
||||||
models:
|
models:
|
||||||
admins_group_manager:
|
gestionnaire:
|
||||||
one: Gestionnaire
|
one: Gestionnaire
|
||||||
other: Gestionnaires
|
other: Gestionnaires
|
|
@ -1,9 +1,9 @@
|
||||||
fr:
|
fr:
|
||||||
activerecord:
|
activerecord:
|
||||||
attributes:
|
attributes:
|
||||||
admins_group:
|
groupe_gestionnaire:
|
||||||
admins_group_managers: Gestionnaires
|
gestionnaires: Gestionnaires
|
||||||
models:
|
models:
|
||||||
admins_group:
|
groupe_gestionnaire:
|
||||||
one: Groupe d'administrateurs
|
one: Groupe d'administrateurs
|
||||||
other: Groupes d'administrateurs
|
other: Groupes d'administrateurs
|
|
@ -1,4 +0,0 @@
|
||||||
en:
|
|
||||||
admins_group_mailer:
|
|
||||||
notify_added_admins_group_managers:
|
|
||||||
email_body: "You were assigned as manager on the admins group %{admins_group_name} on %{application_name} by « %{email} »"
|
|
|
@ -1,4 +0,0 @@
|
||||||
fr:
|
|
||||||
admins_group_mailer:
|
|
||||||
notify_added_admins_group_managers:
|
|
||||||
email_body: "Vous venez d’être nommé gestionnaire du groupe %{admins_group_name} sur %{application_name} par « %{email} »."
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
en:
|
||||||
|
groupe_gestionnaire_mailer:
|
||||||
|
notify_added_gestionnaires:
|
||||||
|
email_body: "You were assigned as manager on the admins group %{groupe_gestionnaire_name} on %{application_name} by « %{email} »"
|
|
@ -0,0 +1,4 @@
|
||||||
|
fr:
|
||||||
|
groupe_gestionnaire_mailer:
|
||||||
|
notify_added_gestionnaires:
|
||||||
|
email_body: "Vous venez d’être nommé gestionnaire du groupe %{groupe_gestionnaire_name} sur %{application_name} par « %{email} »."
|
|
@ -8,14 +8,14 @@ en:
|
||||||
go_instructor: "Switch to instructor"
|
go_instructor: "Switch to instructor"
|
||||||
go_expert: "Switch to expert"
|
go_expert: "Switch to expert"
|
||||||
go_admin: "Switch to administrator"
|
go_admin: "Switch to administrator"
|
||||||
go_admins_group_manager: "Switch to admins group manager"
|
go_gestionnaire: "Switch to admins group manager"
|
||||||
profile: "See my profile"
|
profile: "See my profile"
|
||||||
logout: "Log out"
|
logout: "Log out"
|
||||||
my_account: "My account"
|
my_account: "My account"
|
||||||
connected_as: "connected as %{profile}"
|
connected_as: "connected as %{profile}"
|
||||||
instructeur: instructor
|
instructeur: instructor
|
||||||
administrateur: admin
|
administrateur: admin
|
||||||
admins_group_manager: admins group manager
|
gestionnaire: admins group manager
|
||||||
expert: expert
|
expert: expert
|
||||||
user: user
|
user: user
|
||||||
guest: guest
|
guest: guest
|
||||||
|
|
|
@ -8,14 +8,14 @@ fr:
|
||||||
go_instructor: "Passer en instructeur"
|
go_instructor: "Passer en instructeur"
|
||||||
go_expert: "Passer en expert"
|
go_expert: "Passer en expert"
|
||||||
go_admin: "Passer en administrateur"
|
go_admin: "Passer en administrateur"
|
||||||
go_admins_group_manager: "Passer en gestionnaire"
|
go_gestionnaire: "Passer en gestionnaire"
|
||||||
profile: "Voir mon profil"
|
profile: "Voir mon profil"
|
||||||
logout: "Se déconnecter"
|
logout: "Se déconnecter"
|
||||||
my_account: "Mon compte"
|
my_account: "Mon compte"
|
||||||
connected_as: "connecté en tant qu’%{profile}"
|
connected_as: "connecté en tant qu’%{profile}"
|
||||||
instructeur: instructeur
|
instructeur: instructeur
|
||||||
administrateur: administrateur
|
administrateur: administrateur
|
||||||
admins_group_manager: gestionnaire
|
gestionnaire: gestionnaire
|
||||||
expert: expert
|
expert: expert
|
||||||
user: usager
|
user: usager
|
||||||
guest: invité
|
guest: invité
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
fr:
|
fr:
|
||||||
manager:
|
manager:
|
||||||
admins_groups:
|
groupe_gestionnaires:
|
||||||
add_admins_group_manager:
|
add_gestionnaire:
|
||||||
wrong_address:
|
wrong_address:
|
||||||
one: "%{emails} n’est pas une adresse email valide"
|
one: "%{emails} n’est pas une adresse email valide"
|
||||||
other: "%{emails} ne sont pas des adresses emails valides"
|
other: "%{emails} ne sont pas des adresses emails valides"
|
||||||
|
|
|
@ -57,10 +57,10 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
if ENV['ADMINS_GROUP_ENABLED'] == 'enabled' # can be removed if needed when EVERY PARTS of the feature will be merged / from env.example.optional
|
if ENV['ADMINS_GROUP_ENABLED'] == 'enabled' # can be removed if needed when EVERY PARTS of the feature will be merged / from env.example.optional
|
||||||
resources :admins_group_managers, path: 'gestionnaires', only: [:index, :show, :edit, :update]
|
resources :gestionnaires, only: [:index, :show, :edit, :update]
|
||||||
|
|
||||||
resources :admins_groups, path: 'groupe_administrateurs', only: [:index, :show, :new, :create, :edit, :update] do
|
resources :groupe_gestionnaires, path: 'groupe_administrateurs', only: [:index, :show, :new, :create, :edit, :update] do
|
||||||
post 'add_admins_group_manager', on: :member
|
post 'add_gestionnaire', on: :member
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -476,11 +476,11 @@ Rails.application.routes.draw do
|
||||||
if ENV['ADMINS_GROUP_ENABLED'] == 'enabled' # can be removed if needed when EVERY PARTS of the feature will be merged / from env.example.optional
|
if ENV['ADMINS_GROUP_ENABLED'] == 'enabled' # can be removed if needed when EVERY PARTS of the feature will be merged / from env.example.optional
|
||||||
|
|
||||||
#
|
#
|
||||||
# Admins Group Manager (gestionnaire)
|
# Gestionnaire
|
||||||
#
|
#
|
||||||
|
|
||||||
scope module: 'admins_group_managers', path: 'gestionnaire', as: 'admins_group_manager' do
|
scope module: 'gestionnaires', as: 'gestionnaire' do
|
||||||
resources :admins_groups, path: 'groupe_administrateurs', only: [:index, :create]
|
resources :groupe_gestionnaires, path: 'groupe_administrateurs', only: [:index, :create]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
class CreateAdminsGroupManagers < ActiveRecord::Migration[7.0]
|
|
||||||
def change
|
|
||||||
create_table "admins_group_managers" do |t|
|
|
||||||
t.bigint :user_id, null: false
|
|
||||||
t.index [:user_id], name: :index_admins_group_managers_on_user_id
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,15 +0,0 @@
|
||||||
class CreateAdminsGroups < ActiveRecord::Migration[7.0]
|
|
||||||
def change
|
|
||||||
create_table "admins_groups" do |t|
|
|
||||||
t.string :name, null: false
|
|
||||||
t.references :admins_group
|
|
||||||
t.index [:name], name: :index_admins_groups_on_name
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
|
|
||||||
create_join_table :admins_groups, :admins_group_managers do |t|
|
|
||||||
t.index [:admins_group_id, :admins_group_manager_id], name: :index_on_admins_group_and_admins_group_manager
|
|
||||||
t.index [:admins_group_manager_id, :admins_group_id], name: :index_on_admins_group_manager_and_admins_group
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
class AddAdminsGroupToAdministrateurs < ActiveRecord::Migration[7.0]
|
|
||||||
disable_ddl_transaction!
|
|
||||||
|
|
||||||
def change
|
|
||||||
add_reference :administrateurs, :admins_group, index: { algorithm: :concurrently }, null: true
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
class AddForeignKeyAdminsGroupToAdministrateurs < ActiveRecord::Migration[7.0]
|
|
||||||
def change
|
|
||||||
add_foreign_key :administrateurs, :admins_groups, validate: false
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
class ValidateForeignKeyAdminsGroupToAdministrateurs < ActiveRecord::Migration[7.0]
|
|
||||||
def change
|
|
||||||
validate_foreign_key :administrateurs, :admins_groups
|
|
||||||
end
|
|
||||||
end
|
|
9
db/migrate/20230813091937_create_gestionnaires.rb
Normal file
9
db/migrate/20230813091937_create_gestionnaires.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class CreateGestionnaires < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
create_table "gestionnaires" do |t|
|
||||||
|
t.bigint :user_id, null: false
|
||||||
|
t.index [:user_id], name: :index_gestionnaires_on_user_id
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
15
db/migrate/20230813091938_create_groupe_gestionnaires.rb
Normal file
15
db/migrate/20230813091938_create_groupe_gestionnaires.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
class CreateGroupeGestionnaires < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
create_table "groupe_gestionnaires" do |t|
|
||||||
|
t.string :name, null: false
|
||||||
|
t.references :groupe_gestionnaire
|
||||||
|
t.index [:name], name: :index_groupe_gestionnaires_on_name
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
create_join_table :groupe_gestionnaires, :gestionnaires do |t|
|
||||||
|
t.index [:groupe_gestionnaire_id, :gestionnaire_id], name: :index_on_groupe_gestionnaire_and_gestionnaire
|
||||||
|
t.index [:gestionnaire_id, :groupe_gestionnaire_id], name: :index_on_gestionnaire_and_groupe_gestionnaire
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,7 @@
|
||||||
|
class AddGroupeGestionnaireToAdministrateurs < ActiveRecord::Migration[7.0]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def change
|
||||||
|
add_reference :administrateurs, :groupe_gestionnaire, index: { algorithm: :concurrently }, null: true
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddForeignKeyGroupeGestionnaireToAdministrateurs < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_foreign_key :administrateurs, :groupe_gestionnaires, validate: false
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ValidateForeignKeyGroupeGestionnaireToAdministrateurs < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
validate_foreign_key :administrateurs, :groupe_gestionnaires
|
||||||
|
end
|
||||||
|
end
|
52
db/schema.rb
52
db/schema.rb
|
@ -61,11 +61,11 @@ ActiveRecord::Schema[7.0].define(version: 2023_09_28_083809) do
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "administrateurs", id: :serial, force: :cascade do |t|
|
create_table "administrateurs", id: :serial, force: :cascade do |t|
|
||||||
t.bigint "admins_group_id"
|
|
||||||
t.datetime "created_at", precision: 6
|
t.datetime "created_at", precision: 6
|
||||||
|
t.bigint "groupe_gestionnaire_id"
|
||||||
t.datetime "updated_at", precision: 6
|
t.datetime "updated_at", precision: 6
|
||||||
t.bigint "user_id", null: false
|
t.bigint "user_id", null: false
|
||||||
t.index ["admins_group_id"], name: "index_administrateurs_on_admins_group_id"
|
t.index ["groupe_gestionnaire_id"], name: "index_administrateurs_on_groupe_gestionnaire_id"
|
||||||
t.index ["user_id"], name: "index_administrateurs_on_user_id"
|
t.index ["user_id"], name: "index_administrateurs_on_user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -90,29 +90,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_09_28_083809) do
|
||||||
t.index ["procedure_id"], name: "index_administrateurs_procedures_on_procedure_id"
|
t.index ["procedure_id"], name: "index_administrateurs_procedures_on_procedure_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "admins_group_managers", force: :cascade do |t|
|
|
||||||
t.datetime "created_at", null: false
|
|
||||||
t.datetime "updated_at", null: false
|
|
||||||
t.bigint "user_id", null: false
|
|
||||||
t.index ["user_id"], name: "index_admins_group_managers_on_user_id"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "admins_group_managers_groups", id: false, force: :cascade do |t|
|
|
||||||
t.bigint "admins_group_id", null: false
|
|
||||||
t.bigint "admins_group_manager_id", null: false
|
|
||||||
t.index ["admins_group_id", "admins_group_manager_id"], name: "index_on_admins_group_and_admins_group_manager"
|
|
||||||
t.index ["admins_group_manager_id", "admins_group_id"], name: "index_on_admins_group_manager_and_admins_group"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "admins_groups", force: :cascade do |t|
|
|
||||||
t.bigint "admins_group_id"
|
|
||||||
t.datetime "created_at", null: false
|
|
||||||
t.string "name", null: false
|
|
||||||
t.datetime "updated_at", null: false
|
|
||||||
t.index ["admins_group_id"], name: "index_admins_groups_on_admins_group_id"
|
|
||||||
t.index ["name"], name: "index_admins_groups_on_name"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "api_tokens", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
create_table "api_tokens", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||||
t.bigint "administrateur_id", null: false
|
t.bigint "administrateur_id", null: false
|
||||||
t.bigint "allowed_procedure_ids", array: true
|
t.bigint "allowed_procedure_ids", array: true
|
||||||
|
@ -650,6 +627,29 @@ ActiveRecord::Schema[7.0].define(version: 2023_09_28_083809) do
|
||||||
t.index ["groupe_instructeur_id"], name: "index_contact_informations_on_groupe_instructeur_id"
|
t.index ["groupe_instructeur_id"], name: "index_contact_informations_on_groupe_instructeur_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "gestionnaires", force: :cascade do |t|
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.bigint "user_id", null: false
|
||||||
|
t.index ["user_id"], name: "index_gestionnaires_on_user_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "gestionnaires_groupe_gestionnaires", id: false, force: :cascade do |t|
|
||||||
|
t.bigint "gestionnaire_id", null: false
|
||||||
|
t.bigint "groupe_gestionnaire_id", null: false
|
||||||
|
t.index ["gestionnaire_id", "groupe_gestionnaire_id"], name: "index_on_gestionnaire_and_groupe_gestionnaire"
|
||||||
|
t.index ["groupe_gestionnaire_id", "gestionnaire_id"], name: "index_on_groupe_gestionnaire_and_gestionnaire"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "groupe_gestionnaires", force: :cascade do |t|
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.bigint "groupe_gestionnaire_id"
|
||||||
|
t.string "name", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["groupe_gestionnaire_id"], name: "index_groupe_gestionnaires_on_groupe_gestionnaire_id"
|
||||||
|
t.index ["name"], name: "index_groupe_gestionnaires_on_name"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "groupe_instructeurs", force: :cascade do |t|
|
create_table "groupe_instructeurs", force: :cascade do |t|
|
||||||
t.boolean "closed", default: false
|
t.boolean "closed", default: false
|
||||||
t.datetime "created_at", precision: 6, null: false
|
t.datetime "created_at", precision: 6, null: false
|
||||||
|
@ -1059,7 +1059,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_09_28_083809) do
|
||||||
|
|
||||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||||
add_foreign_key "administrateurs", "admins_groups"
|
add_foreign_key "administrateurs", "groupe_gestionnaires"
|
||||||
add_foreign_key "administrateurs", "users"
|
add_foreign_key "administrateurs", "users"
|
||||||
add_foreign_key "administrateurs_instructeurs", "administrateurs"
|
add_foreign_key "administrateurs_instructeurs", "administrateurs"
|
||||||
add_foreign_key "administrateurs_instructeurs", "instructeurs"
|
add_foreign_key "administrateurs_instructeurs", "instructeurs"
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
sequence(:admins_group_manager_email) { |n| "admins_group_manager#{n}@demarches-simplifiees.fr" }
|
|
||||||
|
|
||||||
factory :admins_group_manager do
|
|
||||||
user { association :user, email: email, password: password }
|
|
||||||
|
|
||||||
transient do
|
|
||||||
email { generate(:admins_group_manager_email) }
|
|
||||||
password { 'somethingverycomplated!' }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
12
spec/factories/gestionnaire.rb
Normal file
12
spec/factories/gestionnaire.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
FactoryBot.define do
|
||||||
|
sequence(:gestionnaire_email) { |n| "gestionnaire#{n}@demarches-simplifiees.fr" }
|
||||||
|
|
||||||
|
factory :gestionnaire do
|
||||||
|
user { association :user, email: email, password: password }
|
||||||
|
|
||||||
|
transient do
|
||||||
|
email { generate(:gestionnaire_email) }
|
||||||
|
password { 'somethingverycomplated!' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,5 +1,5 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :admins_group do
|
factory :groupe_gestionnaire do
|
||||||
sequence(:name) { |n| "Group #{n}" }
|
sequence(:name) { |n| "Group #{n}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,16 +0,0 @@
|
||||||
RSpec.describe AdminsGroupMailer, type: :mailer do
|
|
||||||
describe '#notify_added_admins_group_managers' do
|
|
||||||
let(:admins_group) { create(:admins_group) }
|
|
||||||
|
|
||||||
let(:admins_group_managers_to_add) { [create(:admins_group_manager, email: 'int3@g'), create(:admins_group_manager, email: 'int4@g')] }
|
|
||||||
|
|
||||||
let(:current_super_admin_email) { 'toto@email.com' }
|
|
||||||
|
|
||||||
subject { described_class.notify_added_admins_group_managers(admins_group, admins_group_managers_to_add, current_super_admin_email) }
|
|
||||||
|
|
||||||
before { admins_group_managers_to_add.each { admins_group.add(_1) } }
|
|
||||||
|
|
||||||
it { expect(subject.body).to include('Vous venez d’être nommé gestionnaire du groupe') }
|
|
||||||
it { expect(subject.bcc).to match_array(['int3@g', 'int4@g']) }
|
|
||||||
end
|
|
||||||
end
|
|
16
spec/mailers/groupe_gestionnaire_mailer_spec.rb
Normal file
16
spec/mailers/groupe_gestionnaire_mailer_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
RSpec.describe GroupeGestionnaireMailer, type: :mailer do
|
||||||
|
describe '#notify_added_gestionnaires' do
|
||||||
|
let(:groupe_gestionnaire) { create(:groupe_gestionnaire) }
|
||||||
|
|
||||||
|
let(:gestionnaires_to_add) { [create(:gestionnaire, email: 'int3@g'), create(:gestionnaire, email: 'int4@g')] }
|
||||||
|
|
||||||
|
let(:current_super_admin_email) { 'toto@email.com' }
|
||||||
|
|
||||||
|
subject { described_class.notify_added_gestionnaires(groupe_gestionnaire, gestionnaires_to_add, current_super_admin_email) }
|
||||||
|
|
||||||
|
before { gestionnaires_to_add.each { groupe_gestionnaire.add(_1) } }
|
||||||
|
|
||||||
|
it { expect(subject.body).to include('Vous venez d’être nommé gestionnaire du groupe') }
|
||||||
|
it { expect(subject.bcc).to match_array(['int3@g', 'int4@g']) }
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,14 +0,0 @@
|
||||||
class AdminsGroupMailerPreview < ActionMailer::Preview
|
|
||||||
def notify_added_admins_group_managers
|
|
||||||
admins_group = AdminsGroup.new(name: 'un groupe d\'admin')
|
|
||||||
current_super_admin_email = 'admin@dgfip.com'
|
|
||||||
admins_group_managers = [AdminsGroupManager.new(user: user)]
|
|
||||||
AdminsGroupMailer.notify_added_admins_group_managers(admins_group, admins_group_managers, current_super_admin_email)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def user
|
|
||||||
User.new(id: 10, email: 'test@exemple.fr')
|
|
||||||
end
|
|
||||||
end
|
|
14
spec/mailers/previews/groupe_gestionnaire_mailer_preview.rb
Normal file
14
spec/mailers/previews/groupe_gestionnaire_mailer_preview.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
class GroupeGestionnaireMailerPreview < ActionMailer::Preview
|
||||||
|
def notify_added_gestionnaires
|
||||||
|
groupe_gestionnaire = GroupeGestionnaire.new(name: 'un groupe d\'admin')
|
||||||
|
current_super_admin_email = 'admin@dgfip.com'
|
||||||
|
gestionnaires = [Gestionnaire.new(user: user)]
|
||||||
|
GroupeGestionnaireMailer.notify_added_gestionnaires(groupe_gestionnaire, gestionnaires, current_super_admin_email)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def user
|
||||||
|
User.new(id: 10, email: 'test@exemple.fr')
|
||||||
|
end
|
||||||
|
end
|
|
@ -24,9 +24,9 @@ class UserMailerPreview < ActionMailer::Preview
|
||||||
UserMailer.invite_instructeur(user, 'aedfa0d0')
|
UserMailer.invite_instructeur(user, 'aedfa0d0')
|
||||||
end
|
end
|
||||||
|
|
||||||
def invite_admins_group_manager
|
def invite_gestionnaire
|
||||||
admins_group = AdminsGroup.new(name: 'Root admins group')
|
groupe_gestionnaire = GroupeGestionnaire.new(name: 'Root admins group')
|
||||||
UserMailer.invite_admins_group_manager(user, 'aedfa0d0', admins_group)
|
UserMailer.invite_gestionnaire(user, 'aedfa0d0', groupe_gestionnaire)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -3,7 +3,7 @@ describe Administrateur, type: :model do
|
||||||
|
|
||||||
describe 'associations' do
|
describe 'associations' do
|
||||||
it { is_expected.to have_and_belong_to_many(:instructeurs) }
|
it { is_expected.to have_and_belong_to_many(:instructeurs) }
|
||||||
it { is_expected.to belong_to(:admins_group).optional }
|
it { is_expected.to belong_to(:groupe_gestionnaire).optional }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#can_be_deleted?" do
|
describe "#can_be_deleted?" do
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
describe AdminsGroupManager, type: :model do
|
|
||||||
describe 'associations' do
|
|
||||||
it { is_expected.to have_and_belong_to_many(:admins_groups) }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
describe AdminsGroup, type: :model do
|
|
||||||
describe 'associations' do
|
|
||||||
it { is_expected.to belong_to(:admins_group).optional }
|
|
||||||
it { is_expected.to have_many(:children) }
|
|
||||||
it { is_expected.to have_many(:administrateurs) }
|
|
||||||
it { is_expected.to have_and_belong_to_many(:admins_group_managers) }
|
|
||||||
end
|
|
||||||
end
|
|
5
spec/models/gestionnaire_spec.rb
Normal file
5
spec/models/gestionnaire_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
describe Gestionnaire, type: :model do
|
||||||
|
describe 'associations' do
|
||||||
|
it { is_expected.to have_and_belong_to_many(:groupe_gestionnaires) }
|
||||||
|
end
|
||||||
|
end
|
8
spec/models/groupe_gestionnaire_spec.rb
Normal file
8
spec/models/groupe_gestionnaire_spec.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
describe GroupeGestionnaire, type: :model do
|
||||||
|
describe 'associations' do
|
||||||
|
it { is_expected.to belong_to(:groupe_gestionnaire).optional }
|
||||||
|
it { is_expected.to have_many(:children) }
|
||||||
|
it { is_expected.to have_many(:administrateurs) }
|
||||||
|
it { is_expected.to have_and_belong_to_many(:gestionnaires) }
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue