mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-06 23:48:03 +08:00
Merge pull request #185 from okriuchykhin/global-notifications-SCI-444
Initial code for system notifications [SCI-444]
This commit is contained in:
commit
71458a890b
2 changed files with 26 additions and 0 deletions
16
app/helpers/notifications_helper.rb
Normal file
16
app/helpers/notifications_helper.rb
Normal 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
|
10
lib/tasks/notifications.rake
Normal file
10
lib/tasks/notifications.rake
Normal 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
|
Loading…
Reference in a new issue