Skip to content

Commit

Permalink
Merge branch 'feature/import-2023-08-21'
Browse files Browse the repository at this point in the history
  • Loading branch information
maatinito committed Jan 10, 2024
2 parents 5972f6c + 2432e99 commit 0dac126
Show file tree
Hide file tree
Showing 50 changed files with 293 additions and 672 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ gem 'lograge'
gem 'logstash-event'
gem 'mailjet', require: false
gem 'matrix' # needed by prawn and not default in ruby 3.1
gem 'mini_magick'
gem 'net-imap', require: false # See https://github.com/mikel/mail/pull/1439
gem 'net-pop', require: false # same
gem 'net-smtp', require: false # same
Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ DEPENDENCIES
matrix
memory_profiler
mina
mini_magick
net-imap
net-pop
net-smtp
Expand Down
1 change: 0 additions & 1 deletion app/controllers/api/public/v1/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class API::Public::V1::DossiersController < API::Public::V1::BaseController
def create
dossier = Dossier.new(
revision: @procedure.active_revision,
groupe_instructeur: @procedure.defaut_groupe_instructeur_for_new_dossier,
state: Dossier.states.fetch(:brouillon),
prefilled: true
)
Expand Down
54 changes: 18 additions & 36 deletions app/controllers/instructeurs/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,28 +224,34 @@ def stats

def email_usagers
@procedure = procedure
@commentaire = Commentaire.new
@email_usagers_dossiers = email_usagers_dossiers
@dossiers_count = @email_usagers_dossiers.count
@groupe_instructeurs = email_usagers_groupe_instructeurs_label
@bulk_messages = BulkMessage.includes(:groupe_instructeurs).where(groupe_instructeurs: { id: current_instructeur.groupe_instructeur_ids, procedure: procedure })
@bulk_messages = BulkMessage.includes(:groupe_instructeurs).where(groupe_instructeurs: { procedure: procedure })
@bulk_message = current_instructeur.bulk_messages.build
@dossiers_without_groupe_count = procedure.dossiers.state_brouillon.for_groupe_instructeur(nil).count
end

def create_multiple_commentaire
@procedure = procedure
errors = []

email_usagers_dossiers.each do |dossier|
commentaire = CommentaireService.create(current_instructeur, dossier, commentaire_params)
bulk_message = current_instructeur.bulk_messages.build(bulk_message_params)
dossiers = procedure.dossiers.state_brouillon.for_groupe_instructeur(nil)
dossiers.each do |dossier|
commentaire = CommentaireService.create(current_instructeur, dossier, bulk_message_params.except(:targets))
if commentaire.errors.empty?
commentaire.dossier.update!(last_commentaire_updated_at: Time.zone.now)
else
errors << dossier.id
end
end

valid_dossiers_count = email_usagers_dossiers.count - errors.count
create_bulk_message_mail(valid_dossiers_count, Dossier.states.fetch(:brouillon))
valid_dossiers_count = dossiers.count - errors.count
bulk_message.assign_attributes(
dossier_count: valid_dossiers_count,
dossier_state: Dossier.states.fetch(:brouillon),
sent_at: Time.zone.now,
instructeur_id: current_instructeur.id,
groupe_instructeurs: GroupeInstructeur.for_dossiers(dossiers)
)
bulk_message.save!

if errors.empty?
flash[:notice] = "Tous les messages ont été envoyés avec succès"
Expand All @@ -262,18 +268,6 @@ def administrateurs

private

def create_bulk_message_mail(dossier_count, dossier_state)
BulkMessage.create(
dossier_count: dossier_count,
dossier_state: dossier_state,
body: commentaire_params[:body],
sent_at: Time.zone.now,
instructeur_id: current_instructeur.id,
piece_jointe: commentaire_params[:piece_jointe],
groupe_instructeurs: email_usagers_groupe_instructeurs
)
end

def assign_to_params
params.require(:assign_to)
.permit(:instant_expert_avis_email_notifications_enabled, :instant_email_dossier_notifications_enabled, :instant_email_message_notifications_enabled, :daily_email_notifications_enabled, :weekly_email_notifications_enabled)
Expand Down Expand Up @@ -355,20 +349,8 @@ def current_filters
@current_filters ||= procedure_presentation.filters.fetch(statut, [])
end

def email_usagers_dossiers
procedure.dossiers.state_brouillon.where(groupe_instructeur: current_instructeur.groupe_instructeur_ids).includes(:groupe_instructeur)
end

def email_usagers_groupe_instructeurs_label
email_usagers_dossiers.map(&:groupe_instructeur).uniq.map(&:label)
end

def email_usagers_groupe_instructeurs
email_usagers_dossiers.map(&:groupe_instructeur).uniq
end

def commentaire_params
params.require(:commentaire).permit(:body, :piece_jointe)
def bulk_message_params
params.require(:bulk_message).permit(:body)
end
end
end
62 changes: 0 additions & 62 deletions app/controllers/manager/demandes_controller.rb

This file was deleted.

17 changes: 17 additions & 0 deletions app/controllers/procedures_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class ProceduresController < ApplicationController
before_action :retrieve_procedure

def logo
if @procedure.logo.attached?
redirect_to url_for(@procedure.logo.variant(:email))
else
redirect_to image_url(PROCEDURE_DEFAULT_LOGO_SRC)
end
end

private

def retrieve_procedure
@procedure = Procedure.find(params[:id])
end
end
1 change: 0 additions & 1 deletion app/controllers/users/commencer_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def retrieve_procedure_with_closed
def build_prefilled_dossier
@prefilled_dossier = Dossier.new(
revision: @revision,
groupe_instructeur: @procedure.defaut_groupe_instructeur_for_new_dossier,
state: Dossier.states.fetch(:brouillon),
prefilled: true
)
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/users/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ def new

dossier = Dossier.new(
revision: params[:brouillon] ? procedure.draft_revision : procedure.active_revision,
groupe_instructeur: procedure.defaut_groupe_instructeur_for_new_dossier,
user: current_user,
state: Dossier.states.fetch(:brouillon)
)
Expand Down Expand Up @@ -561,6 +560,7 @@ def set_dossier_as_editing_fork

def update_dossier_and_compute_errors
errors = []

@dossier.assign_attributes(champs_public_params)
if @dossier.champs_public_all.any?(&:changed_for_autosave?)
@dossier.last_champ_updated_at = Time.zone.now
Expand All @@ -578,7 +578,6 @@ def submit_dossier_and_compute_errors
@dossier.valid?(**submit_validation_options)
errors += format_errors(errors: @dossier.errors)
errors += format_errors(errors: @dossier.check_mandatory_and_visible_champs)

errors
end

Expand Down
4 changes: 0 additions & 4 deletions app/dashboards/demande_dashboard.rb

This file was deleted.

21 changes: 0 additions & 21 deletions app/helpers/demande_helper.rb

This file was deleted.

8 changes: 4 additions & 4 deletions app/helpers/procedure_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def can_manage_groupe_instructeurs?(procedure)
end

def can_send_groupe_message?(procedure)
procedure.dossiers
.state_brouillon
.includes(:groupe_instructeur)
.exists?(groupe_instructeur: current_instructeur.groupe_instructeurs)
total_groupe_instructeur_on_procedure = procedure.groupe_instructeurs.active.count
total_groupe_instructeur_on_instructeur = current_instructeur.groupe_instructeurs.active.where(procedure: procedure).count

total_groupe_instructeur_on_procedure == total_groupe_instructeur_on_instructeur
end

def url_or_email_to_lien_dpo(procedure)
Expand Down
5 changes: 0 additions & 5 deletions app/jobs/pipedrive_accepts_deals_job.rb

This file was deleted.

5 changes: 0 additions & 5 deletions app/jobs/pipedrive_refuses_deals_job.rb

This file was deleted.

4 changes: 0 additions & 4 deletions app/lib/biz_dev.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ module BizDev
def self.full_name(administration_id)
NAME
end

def self.pipedrive_id(administration_id)
PIPEDRIVE_ID
end
end
82 changes: 0 additions & 82 deletions app/lib/pipedrive/api.rb

This file was deleted.

Loading

0 comments on commit 0dac126

Please sign in to comment.