Class: UINotifications::Tasks::TaskPausedAdmin
- Inherits:
-
Base
- Object
- Base
- Base
- UINotifications::Tasks::TaskPausedAdmin
show all
- Defined in:
- app/services/ui_notifications/tasks/task_paused_admin.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #troubleshooting_help_generator
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!
Notification.where(notification_blueprint_id: blueprint.id).each(&:destroy)
notification = ::Notification.new(
:audience => Notification::AUDIENCE_ADMIN,
:notification_blueprint => blueprint,
:initiator => initiator,
:subject => subject,
:message => message
)
notification.send(:set_custom_attributes) 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 message
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
|