Class: UINotifications::Tasks::TaskPausedAdmin
- Inherits:
-
Tasks::Base
- Object
- Tasks::Base
- UINotifications::Tasks::TaskPausedAdmin
- Defined in:
- app/services/ui_notifications/tasks/task_paused_admin.rb
Instance Method Summary collapse
Instance Method Details
#blueprint ⇒ Object
29 30 31 |
# File 'app/services/ui_notifications/tasks/task_paused_admin.rb', line 29 def blueprint @blueprint ||= NotificationBlueprint.unscoped.find_by(:name => 'tasks_paused_admin') end |
#deliver! ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/ui_notifications/tasks/task_paused_admin.rb', line 4 def deliver! # delete previous notifications about paused tasks first Notification.where(notification_blueprint_id: blueprint.id).each(&:destroy) notification = ::Notification.new( :audience => Notification::AUDIENCE_ADMIN, :notification_blueprint => blueprint, :initiator => initiator, :subject => subject, :message => ) notification.send(:set_custom_attributes) # to add links from blueprint notification.actions['links'] ||= [] if troubleshooting_help_generator troubleshooting_link = troubleshooting_help_generator.troubleshooting_link(generic_only: true) notification.actions['links'] << troubleshooting_link.to_h(capitalize_title: true) if troubleshooting_link end notification.save! notification end |
#initiator ⇒ Object
25 26 27 |
# File 'app/services/ui_notifications/tasks/task_paused_admin.rb', line 25 def initiator User.anonymous_admin end |
#message ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/services/ui_notifications/tasks/task_paused_admin.rb', line 33 def return @message if @message tasks_count = ForemanTasks::Task.where(state: 'paused').count @message = n_('There is %{count} paused task in the system that need attention', 'There are %{count} paused tasks in the system that need attention', tasks_count) % { count: tasks_count } end |