amelioration(safe_mailer): ajoute au manager la fonction pour configurer le routage des mails sur un fournisseur unique
Update app/mailers/devise_user_mailer.rb Co-authored-by: LeSim <mail@simon.lehericey.net>
This commit is contained in:
parent
d535735155
commit
3e6b82ed9e
7 changed files with 65 additions and 3 deletions
4
app/controllers/manager/safe_mailers_controller.rb
Normal file
4
app/controllers/manager/safe_mailers_controller.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
module Manager
|
||||
class SafeMailersController < Manager::ApplicationController
|
||||
end
|
||||
end
|
43
app/dashboards/safe_mailer_dashboard.rb
Normal file
43
app/dashboards/safe_mailer_dashboard.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
require "administrate/base_dashboard"
|
||||
|
||||
class SafeMailerDashboard < Administrate::BaseDashboard
|
||||
# ATTRIBUTE_TYPES
|
||||
# a hash that describes the type of each of the model's fields.
|
||||
#
|
||||
# Each different type represents an Administrate::Field object,
|
||||
# which determines how the attribute is displayed
|
||||
# on pages throughout the dashboard.
|
||||
ATTRIBUTE_TYPES = {
|
||||
id: Field::Number,
|
||||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime,
|
||||
forced_delivery_method: Field::Enum
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's index page.
|
||||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:id,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
:forced_delivery_method
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:created_at,
|
||||
:updated_at,
|
||||
:forced_delivery_method
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:forced_delivery_method
|
||||
].freeze
|
||||
end
|
|
@ -23,6 +23,6 @@ class DeviseUserMailer < Devise::Mailer
|
|||
end
|
||||
|
||||
def forced_delivery?
|
||||
SafeMailer&.forced_delivery_method.present?
|
||||
SafeMailer.forced_delivery_method.present?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,8 @@ class SafeMailer < ApplicationRecord
|
|||
raise if SafeMailer.count == 1
|
||||
end
|
||||
|
||||
enum forced_delivery_method: Rails.application.config.action_mailer&.balancer_settings&.keys&.map(&:to_s) || []
|
||||
|
||||
def self.forced_delivery_method
|
||||
first&.forced_delivery_method
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require "active_support/core_ext/integer/time"
|
||||
require Rails.root.join("app/lib/balancer_delivery_method")
|
||||
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
@ -76,7 +77,12 @@ Rails.application.configure do
|
|||
config.assets.raise_runtime_errors = true
|
||||
|
||||
# Action Mailer settings
|
||||
config.action_mailer.delivery_method = ENV['HELO_ENABLED'] == 'enabled' ? :helo : :letter_opener
|
||||
ActionMailer::Base.add_delivery_method :balancer, BalancerDeliveryMethod
|
||||
config.action_mailer.balancer_settings = {
|
||||
helo: ENV['HELO_ENABLED'] == 'enabled' ? 100 : 0,
|
||||
letter_opener: ENV['HELO_ENABLED'] == 'enabled' ? 0 : 100
|
||||
}
|
||||
config.action_mailer.delivery_method = :balancer
|
||||
|
||||
config.action_mailer.default_url_options = { host: ENV.fetch("APP_HOST") }
|
||||
config.action_mailer.asset_host = "http://" + ENV.fetch("APP_HOST")
|
||||
|
|
|
@ -71,6 +71,7 @@ Rails.application.routes.draw do
|
|||
resources :outdated_procedures, only: [:index] do
|
||||
patch :bulk_update, on: :collection
|
||||
end
|
||||
resources :safe_mailers, only: [:index, :edit, :update, :destroy]
|
||||
|
||||
post 'demandes/create_administrateur'
|
||||
post 'demandes/refuse_administrateur'
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2023_01_10_181426) do
|
||||
ActiveRecord::Schema.define(version: 2023_01_11_094621) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
|
@ -785,6 +785,12 @@ ActiveRecord::Schema.define(version: 2023_01_10_181426) do
|
|||
t.index ["procedure_id"], name: "index_refused_mails_on_procedure_id"
|
||||
end
|
||||
|
||||
create_table "safe_mailers", force: :cascade do |t|
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.string "forced_delivery_method"
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
end
|
||||
|
||||
create_table "services", force: :cascade do |t|
|
||||
t.bigint "administrateur_id"
|
||||
t.text "adresse"
|
||||
|
|
Loading…
Reference in a new issue