Sha256: ebce703f1901a0de238ea30f7b64ef15bd26c78b04c1d45e05a6a17b8c0faf18
Contents?: true
Size: 1.09 KB
Versions: 17
Compression:
Stored size: 1.09 KB
Contents
module ForemanTasks module Concerns module UserExtensions extend ActiveSupport::Concern included do # rubocop:disable Rails/ReflectionClassName has_many :tasks, :dependent => :nullify, :class_name => ::ForemanTasks::Task.name # rubocop:enable Rails/ReflectionClassName before_validation :attach_task_mail_notifications, on: :create end def attach_task_mail_notifications return if ::ForemanSeeder.is_seeding org_admin_role = Role.find_by(name: 'Organization admin') admin_by_role = org_admin_role && (roles.map(&:id) & ([org_admin_role.id] + org_admin_role.cloned_role_ids)).any? return unless admin || admin_by_role notification = MailNotification.find_by(name: 'long_running_tasks') return if notification.nil? if user_mail_notifications.none? { |n| n.mail_notification_id == notification.id } user_mail_notifications.build(mail_notification_id: notification.id, interval: 'Subscribe') end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems