Merge pull request #185 from okriuchykhin/global-notifications-SCI-444

Initial code for system notifications [SCI-444]
This commit is contained in:
Luka Murn 2016-10-03 16:05:25 +02:00 committed by GitHub
commit 71458a890b
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,16 @@
module NotificationsHelper
def create_system_notification(title, message)
notification = Notification.new
notification.title = title
notification.message = message
notification.type_of = :system_message
notification.transaction do
User.where.not(confirmed_at: nil).find_each do |u|
UserNotification
.new(user: u, notification: notification, checked: false)
.save!
end
notification.save!
end
end
end

View file

@ -0,0 +1,10 @@
namespace :notifications do
desc 'Creates new system notification for all active users'
task :new_release => :environment do
include NotificationsHelper
puts 'Creation of system notification for all active users with link to release notes'
create_system_notification('New release', 'http://scinote.net/docs/release-notes/')
end
end