Show More
@@ -27,13 +27,14 b" CONTEXT_ONLY_FAVORITES = 'only_favorites" | |||||
27 |
|
27 | |||
28 | def get_notifications(context, settings_manager): |
|
28 | def get_notifications(context, settings_manager): | |
29 | usernames = settings_manager.get_notification_usernames() |
|
29 | usernames = settings_manager.get_notification_usernames() | |
|
30 | fav_tags = settings_manager.get_fav_tags() | |||
30 | new_notifications_count = 0 |
|
31 | new_notifications_count = 0 | |
31 | if usernames: |
|
32 | if usernames or fav_tags: | |
32 | last_notification_id = settings_manager.get_setting( |
|
33 | last_notification_id = settings_manager.get_setting( | |
33 | SETTING_LAST_NOTIFICATION_ID) |
|
34 | SETTING_LAST_NOTIFICATION_ID) | |
34 |
|
35 | |||
35 | new_notifications_count = Notification.objects.get_notification_posts( |
|
36 | new_notifications_count = Notification.objects.get_notification_posts( | |
36 | usernames=usernames, last=last_notification_id).only('id').count() |
|
37 | usernames=usernames, last=last_notification_id, fav_tags=fav_tags).only('id').count() | |
37 | context[CONTEXT_NEW_NOTIFICATIONS_COUNT] = new_notifications_count |
|
38 | context[CONTEXT_NEW_NOTIFICATIONS_COUNT] = new_notifications_count | |
38 | context[CONTEXT_USERNAMES] = usernames |
|
39 | context[CONTEXT_USERNAMES] = usernames | |
39 |
|
40 |
@@ -1,4 +1,5 b'' | |||||
1 | from django.db import models |
|
1 | from django.db import models | |
|
2 | from django.db.models import Q | |||
2 | import boards |
|
3 | import boards | |
3 |
|
4 | |||
4 | __author__ = 'neko259' |
|
5 | __author__ = 'neko259' | |
@@ -24,10 +25,10 b' class Ban(models.Model):' | |||||
24 |
|
25 | |||
25 |
|
26 | |||
26 | class NotificationManager(models.Manager): |
|
27 | class NotificationManager(models.Manager): | |
27 | def get_notification_posts(self, usernames: list, last: int = None): |
|
28 | def get_notification_posts(self, usernames: list, last: int = None, fav_tags=None): | |
28 | lower_names = [username.lower() for username in usernames] |
|
29 | lower_names = [username.lower() for username in usernames] | |
29 | posts = boards.models.post.Post.objects.filter( |
|
30 | posts = boards.models.post.Post.objects.filter( | |
30 | notification__name__in=lower_names).distinct() |
|
31 | Q(notification__name__in=lower_names) | Q(thread__tags__in=fav_tags)).distinct() | |
31 | if last is not None: |
|
32 | if last is not None: | |
32 | posts = posts.filter(id__gt=last) |
|
33 | posts = posts.filter(id__gt=last) | |
33 | posts = posts.order_by('-id') |
|
34 | posts = posts.order_by('-id') |
@@ -57,7 +57,7 b'' | |||||
57 | <a href="{% url 'feed' %}?favorites" id="fav-panel-btn">{% trans 'favorites' %} <span id="new-fav-post-count" {% if not new_post_count %}style="display: none" {% endif %}>{{ new_post_count|safe }}</span></a> |
|
57 | <a href="{% url 'feed' %}?favorites" id="fav-panel-btn">{% trans 'favorites' %} <span id="new-fav-post-count" {% if not new_post_count %}style="display: none" {% endif %}>{{ new_post_count|safe }}</span></a> | |
58 | {% endif %} |
|
58 | {% endif %} | |
59 |
|
59 | |||
60 | {% if usernames %} |
|
60 | {% if usernames or tags_str %} | |
61 | <a class="right-link link" href="{% url 'notifications' %}" title="{% trans 'Notifications' %}"> |
|
61 | <a class="right-link link" href="{% url 'notifications' %}" title="{% trans 'Notifications' %}"> | |
62 | {% trans 'Notifications' %} |
|
62 | {% trans 'Notifications' %} | |
63 | {% ifnotequal new_notifications_count 0 %} |
|
63 | {% ifnotequal new_notifications_count 0 %} |
@@ -27,8 +27,10 b' class NotificationView(BaseBoardView):' | |||||
27 | else: |
|
27 | else: | |
28 | notification_usernames = [username] |
|
28 | notification_usernames = [username] | |
29 |
|
29 | |||
|
30 | fav_tags = settings_manager.get_fav_tags() | |||
|
31 | ||||
30 | posts = Notification.objects.get_notification_posts( |
|
32 | posts = Notification.objects.get_notification_posts( | |
31 | usernames=notification_usernames) |
|
33 | usernames=notification_usernames, fav_tags=fav_tags) | |
32 |
|
34 | |||
33 | if username is None: |
|
35 | if username is None: | |
34 | last = posts.first() |
|
36 | last = posts.first() |
General Comments 0
You need to be logged in to leave comments.
Login now