diff --git a/boards/context_processors.py b/boards/context_processors.py --- a/boards/context_processors.py +++ b/boards/context_processors.py @@ -27,13 +27,14 @@ CONTEXT_ONLY_FAVORITES = 'only_favorites def get_notifications(context, settings_manager): usernames = settings_manager.get_notification_usernames() + fav_tags = settings_manager.get_fav_tags() new_notifications_count = 0 - if usernames: + if usernames or fav_tags: last_notification_id = settings_manager.get_setting( SETTING_LAST_NOTIFICATION_ID) new_notifications_count = Notification.objects.get_notification_posts( - usernames=usernames, last=last_notification_id).only('id').count() + usernames=usernames, last=last_notification_id, fav_tags=fav_tags).only('id').count() context[CONTEXT_NEW_NOTIFICATIONS_COUNT] = new_notifications_count context[CONTEXT_USERNAMES] = usernames diff --git a/boards/models/user.py b/boards/models/user.py --- a/boards/models/user.py +++ b/boards/models/user.py @@ -1,4 +1,5 @@ from django.db import models +from django.db.models import Q import boards __author__ = 'neko259' @@ -24,10 +25,10 @@ class Ban(models.Model): class NotificationManager(models.Manager): - def get_notification_posts(self, usernames: list, last: int = None): + def get_notification_posts(self, usernames: list, last: int = None, fav_tags=None): lower_names = [username.lower() for username in usernames] posts = boards.models.post.Post.objects.filter( - notification__name__in=lower_names).distinct() + Q(notification__name__in=lower_names) | Q(thread__tags__in=fav_tags)).distinct() if last is not None: posts = posts.filter(id__gt=last) posts = posts.order_by('-id') diff --git a/boards/templates/boards/base.html b/boards/templates/boards/base.html --- a/boards/templates/boards/base.html +++ b/boards/templates/boards/base.html @@ -57,7 +57,7 @@ {% trans 'favorites' %} {{ new_post_count|safe }} {% endif %} - {% if usernames %} + {% if usernames or tags_str %} {% trans 'Notifications' %} {% ifnotequal new_notifications_count 0 %} diff --git a/boards/views/notifications.py b/boards/views/notifications.py --- a/boards/views/notifications.py +++ b/boards/views/notifications.py @@ -27,8 +27,10 @@ class NotificationView(BaseBoardView): else: notification_usernames = [username] + fav_tags = settings_manager.get_fav_tags() + posts = Notification.objects.get_notification_posts( - usernames=notification_usernames) + usernames=notification_usernames, fav_tags=fav_tags) if username is None: last = posts.first()