diff --git a/app/controllers/manager/email_events_controller.rb b/app/controllers/manager/email_events_controller.rb index bd7b59ff7..4a4cb74c2 100644 --- a/app/controllers/manager/email_events_controller.rb +++ b/app/controllers/manager/email_events_controller.rb @@ -1,4 +1,25 @@ module Manager class EmailEventsController < Manager::ApplicationController + def index + @dolist_enabled = Dolist::API.new.properly_configured? + + super + end + + def generate_dolist_report + email = current_super_admin.email + + DolistReportJob.perform_later(email) + + respond_to do |format| + @message = "Le rapport sera envoyé sur #{email}. Il peut prendre plus d'1h pour être généré." + + format.turbo_stream + + format.html do + redirect_to manager_email_events_path, notice: @message + end + end + end end end diff --git a/app/views/manager/email_events/_index_footer.html.erb b/app/views/manager/email_events/_index_footer.html.erb new file mode 100644 index 000000000..aa4f835cd --- /dev/null +++ b/app/views/manager/email_events/_index_footer.html.erb @@ -0,0 +1,7 @@ + diff --git a/app/views/manager/email_events/generate_dolist_report.turbo_stream.haml b/app/views/manager/email_events/generate_dolist_report.turbo_stream.haml new file mode 100644 index 000000000..efe704452 --- /dev/null +++ b/app/views/manager/email_events/generate_dolist_report.turbo_stream.haml @@ -0,0 +1,2 @@ += turbo_stream.morph "dolist-report-form" do + = @message diff --git a/config/routes.rb b/config/routes.rb index aedd12400..87b74e2b1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -65,7 +65,9 @@ Rails.application.routes.draw do resources :team_accounts, only: [:index, :show] - resources :email_events, only: [:index, :show] + resources :email_events, only: [:index, :show] do + post :generate_dolist_report, on: :collection + end resources :dubious_procedures, only: [:index] resources :outdated_procedures, only: [:index] do