diff --git a/app/controllers/management/events_controller.rb b/app/controllers/management/events_controller.rb index c809481..7f129f7 100644 --- a/app/controllers/management/events_controller.rb +++ b/app/controllers/management/events_controller.rb @@ -34,6 +34,15 @@ module Management @suggestion.save end + def send_acceptance_notifications + @suggestions = Conference.current.events.approved.where acceptance_notification_sent_at: nil + if @suggestions.all?(&:send_acceptance_notification!) + head :no_content + else + head :unprocessable_entity + end + end + private def state_params diff --git a/app/views/management/events/index.html.slim b/app/views/management/events/index.html.slim index 5c1b5e3..ec991a7 100644 --- a/app/views/management/events/index.html.slim +++ b/app/views/management/events/index.html.slim @@ -16,3 +16,7 @@ th.actions tbody = render partial: 'suggestion_group', collection: @suggestion_groups + .panel-footer + .pull-right + = link_to 'Изпрати нотификации на одобрените', send_acceptance_notifications_management_events_path, remote: true, method: :post, data: {confirm: 'Сигурни ли сте'}, class: %w{btn btn-danger} + .clearfix diff --git a/config/routes.rb b/config/routes.rb index 113916d..636156f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,6 +32,7 @@ Rails.application.routes.draw do get 'rejected' get 'undecided' get 'backup' + post 'send_acceptance_notifications' end end end