Class: Katello::UINotifications::Subscriptions::ExpireSoon
- Inherits:
-
Object
- Object
- Katello::UINotifications::Subscriptions::ExpireSoon
- Defined in:
- app/services/katello/ui_notifications/subscriptions/expire_soon.rb
Class Method Summary collapse
- .actions ⇒ Object
- .blueprint ⇒ Object
- .deliver! ⇒ Object
- .message(organization) ⇒ Object
- .notification_already_exists?(subject) ⇒ Boolean
Class Method Details
.actions ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/services/katello/ui_notifications/subscriptions/expire_soon.rb', line 45 def actions { :links => [ { :href => "/subscriptions?search=expires<\"#{Setting[:expire_soon_days]} days from now\"", :title => _('Subscriptions'), :external => true } ] } end |
.blueprint ⇒ Object
57 58 59 60 |
# File 'app/services/katello/ui_notifications/subscriptions/expire_soon.rb', line 57 def blueprint @blueprint ||= NotificationBlueprint.unscoped.find_by( :name => 'subs_expire_soon') end |
.deliver! ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/katello/ui_notifications/subscriptions/expire_soon.rb', line 6 def deliver! ::Organization.unscoped.all.each do |organization| if (notification = notification_already_exists?(organization)) next unless organization.expiring_subscriptions.count.to_s == notification..split(' ').first notification.update( :message => (organization), :actions => actions ) else next unless organization.expiring_subscriptions.count > 0 ::Notification.create!( :subject => organization, :initiator => User.anonymous_admin, :audience => Notification::AUDIENCE_SUBJECT, :message => (organization), :actions => actions, :notification_blueprint => blueprint ) end end end |
.message(organization) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'app/services/katello/ui_notifications/subscriptions/expire_soon.rb', line 36 def (organization) ::UINotifications::StringParser.new( blueprint., :expiring_subs => organization.expiring_subscriptions.count, :subject => organization, :days => Setting[:expire_soon_days] ) end |
.notification_already_exists?(subject) ⇒ Boolean
29 30 31 32 33 34 |
# File 'app/services/katello/ui_notifications/subscriptions/expire_soon.rb', line 29 def notification_already_exists?(subject) subs_expiration_notification = Notification.unscoped.find_by(:subject => subject) return false if subs_expiration_notification.blank? || subs_expiration_notification.notification_blueprint != blueprint subs_expiration_notification end |