added notification_count

This commit is contained in:
nilsding 2014-12-14 15:15:15 +01:00
parent 43474a6c92
commit dec91d474d
3 changed files with 11 additions and 2 deletions

View File

@ -47,6 +47,14 @@ module ApplicationHelper
count.count
end
def notification_count
return 0 unless user_signed_in?
count = Notification.for(current_user).where(new: true)
return nil if count.nil?
return nil unless count.count > 0
count.count
end
def privileged?(user)
(current_user && (current_user == user || current_user.admin?)) ? true : false
end

View File

@ -1 +1 @@
= nav_entry "Notifications", "/notifications/index"
= nav_entry "Notifications", "/notifications/index", badge: notification_count

View File

@ -60,3 +60,4 @@
ago
.notification--icon
%i.fa.fa-comments
- Notification.for(current_user).update_all(new: false)