Skip to content

Commit

Permalink
Merge pull request #601 from etalab/feature/dat-686-gerer-le-mailing-…
Browse files Browse the repository at this point in the history
…pour-la-dgfip

Ajoute un email spécifique pour la sandbox DGFIP
  • Loading branch information
jbfeldis authored Jan 14, 2025
2 parents ca758dd + b7ce69c commit 1a59dee
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 14 deletions.
5 changes: 3 additions & 2 deletions app/lib/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def perform

create_authorization_requests_for_clamart
create_authorization_requests_for_dinum
create_validated_authorization_request(:portail_hubee_demarche_certdc, attributes: { description: nil })
end

def flushdb
Expand Down Expand Up @@ -161,10 +162,10 @@ def create_organization(siret:, name:)
def create_draft_authorization_request(kind, attributes: {})
create_authorization_request_model(
kind,
attributes: attributes.merge(
attributes: {
fill_all_attributes: true,
description: random_description,
)
}.merge(attributes).compact
)
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%= render partial: 'mailer/shared/applicant/header', locals: { entity_name: @authorization_request.applicant.full_name } %>

<%=
t(
'.description',
authorization_request_id: @authorization_request.id,
authorization_request_name: @authorization_request.name,
authorization_request_url: authorization_request_url(@authorization_request),
authorization_request_next_stage_url: next_authorization_request_stage_url(@authorization_request)
)
%>

<%= render partial: 'mailer/shared/applicant/footer', locals: { authorization_definition_name: @authorization_request.definition.name } %>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= render partial: 'mailer/shared/applicant/header', locals: { entity_name: @authorization_request.applicant } %>
<%= render partial: 'mailer/shared/applicant/header', locals: { entity_name: @authorization_request.applicant.full_name } %>

<%=
t(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= render partial: 'mailer/shared/applicant/header', locals: { entity_name: @authorization_request.applicant } %>
<%= render partial: 'mailer/shared/applicant/header', locals: { entity_name: @authorization_request.applicant.full_name } %>

<%=
t(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= render partial: 'mailer/shared/applicant/header', locals: { entity_name: @authorization_request.applicant } %>
<%= render partial: 'mailer/shared/applicant/header', locals: { entity_name: @authorization_request.applicant.full_name } %>

<%=
t(
Expand Down
13 changes: 7 additions & 6 deletions config/environments/sandbox.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "active_support/core_ext/integer/time"
require 'active_support/core_ext/integer/time'

Rails.application.configure do
config.host = ENV.fetch("HOST", "localhost:3000")
config.host = ENV.fetch('HOST', 'localhost:3000')

# Settings specified here will take precedence over those in config/application.rb.

Expand Down Expand Up @@ -53,19 +53,19 @@
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true

if ENV["RAILS_LOG_TO_STDOUT"].present?
if ENV['RAILS_LOG_TO_STDOUT'].present?
config.logger = ActiveSupport::Logger.new(STDOUT)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.tap { |logger| logger.formatter = Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
end

# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]

# Info include generic and useful information about system operation, but avoids logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
# want to log everything, set the level to "debug".
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
Expand All @@ -74,6 +74,7 @@
config.active_job.queue_adapter = :good_job
# config.active_job.queue_name_prefix = "data_pass_production"

config.action_mailer.show_previews = true
config.action_mailer.delivery_method = :mailjet
config.action_mailer.perform_caching = false

Expand Down
8 changes: 8 additions & 0 deletions config/locales/mailer.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ fr:
text: L'équipe DataPass

authorization_request_mailer:
api_impot_particulier_sandbox:
approve:
description: |
Votre habilitation "%{authorization_request_name}" (numéro %{authorization_request_id}) a été validée par nos équipes.
Vous pouvez consulter votre habilitation en suivant le lien suivant: %{authorization_request_url}
Vous pouvez dès à présent poursuivre votre demande pour demander l’accès en production via ce lien : %{authorization_request_next_stage_url}
approve:
subject: Votre habilitation numéro %{authorization_request_id} vient d'être validée
description: |
Expand Down
17 changes: 15 additions & 2 deletions spec/mailers/previews/authorization_request_preview.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
class AuthorizationRequestPreview < ActionMailer::Preview
%w[changes_requested refused revoked validated].each do |state|
[state, "reopening_#{state}"].each do |mth|
{
changes_requested: :request_changes,
refused: :refuse,
revoked: :revoke,
validated: :approve
}.each do |state, event|
[event, "reopening_#{event}"].each do |mth|
next if mth == 'reopening_revoke'

define_method mth do
authorization_request_mailer_method(state, mth)
end
end
end

def approve_dgfip_sandbox
AuthorizationRequestMailer.with(
authorization_request: AuthorizationRequest::APIImpotParticulierSandbox.where(state: :validated).first
).approve
end

private

def authorization_request_mailer_method(state, mth)
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/previews/gdpr_contact_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def params_for(contact)
end

def find_authorization_request_by(contact)
AuthorizationRequest.where.not("data ? '#{contact}_email'").first
AuthorizationRequest.where("data ? '#{contact}_email'").first
end
end

0 comments on commit 1a59dee

Please sign in to comment.