Show More
@@ -6,6 +6,8 b' from boards import settings' | |||||
6 | from boards.models import Post, Tag, Thread |
|
6 | from boards.models import Post, Tag, Thread | |
7 | from boards.settings import SECTION_FORMS, SECTION_VIEW, SECTION_VERSION |
|
7 | from boards.settings import SECTION_FORMS, SECTION_VIEW, SECTION_VERSION | |
8 |
|
8 | |||
|
9 | PATTERN_NEW_POSTS_COUNT = '(+{})' | |||
|
10 | ||||
9 | THEME_CSS = 'css/{}/base_page.css' |
|
11 | THEME_CSS = 'css/{}/base_page.css' | |
10 |
|
12 | |||
11 | CONTEXT_SITE_NAME = 'site_name' |
|
13 | CONTEXT_SITE_NAME = 'site_name' | |
@@ -25,16 +27,20 b" CONTEXT_BANNERS = 'banners'" | |||||
25 | CONTEXT_ONLY_FAVORITES = 'only_favorites' |
|
27 | CONTEXT_ONLY_FAVORITES = 'only_favorites' | |
26 |
|
28 | |||
27 |
|
29 | |||
28 | def get_notifications(context, settings_manager): |
|
30 | def get_notifications(context, settings_manager, fav_tags): | |
29 | usernames = settings_manager.get_notification_usernames() |
|
31 | usernames = settings_manager.get_notification_usernames() | |
30 | fav_tags = settings_manager.get_fav_tags() |
|
32 | ||
31 | new_notifications_count = 0 |
|
33 | new_notifications_count = 0 | |
|
34 | ||||
32 | if usernames or fav_tags: |
|
35 | if usernames or fav_tags: | |
33 | last_notification_id = settings_manager.get_setting( |
|
36 | last_notification_id = settings_manager.get_setting( | |
34 | SETTING_LAST_NOTIFICATION_ID) |
|
37 | SETTING_LAST_NOTIFICATION_ID) | |
35 |
|
38 | |||
36 | new_notifications_count = Notification.objects.get_notification_posts( |
|
39 | new_notifications_count = Notification.objects.get_notification_posts( | |
37 | usernames=usernames, last=last_notification_id, user_settings=settings_manager.get_user_settings()).count() |
|
40 | usernames=usernames, | |
|
41 | last=last_notification_id, | |||
|
42 | user_settings=settings_manager.get_user_settings()).count() | |||
|
43 | ||||
38 | context[CONTEXT_NEW_NOTIFICATIONS_COUNT] = new_notifications_count |
|
44 | context[CONTEXT_NEW_NOTIFICATIONS_COUNT] = new_notifications_count | |
39 | context[CONTEXT_USERNAMES] = usernames |
|
45 | context[CONTEXT_USERNAMES] = usernames | |
40 |
|
46 | |||
@@ -43,7 +49,7 b' def get_new_post_count(context, settings' | |||||
43 | last_posts = settings_manager.get_last_posts() |
|
49 | last_posts = settings_manager.get_last_posts() | |
44 | count = Thread.objects.get_new_post_count(last_posts) |
|
50 | count = Thread.objects.get_new_post_count(last_posts) | |
45 | if count > 0: |
|
51 | if count > 0: | |
46 |
context[CONTEXT_NEW_POST_COUNT] = |
|
52 | context[CONTEXT_NEW_POST_COUNT] = PATTERN_NEW_POSTS_COUNT.format(count) | |
47 |
|
53 | |||
48 |
|
54 | |||
49 | def user_and_ui_processor(request): |
|
55 | def user_and_ui_processor(request): | |
@@ -78,7 +84,7 b' def user_and_ui_processor(request):' | |||||
78 | context[CONTEXT_ONLY_FAVORITES] = settings_manager.get_setting( |
|
84 | context[CONTEXT_ONLY_FAVORITES] = settings_manager.get_setting( | |
79 | SETTING_ONLY_FAVORITES, default=False) |
|
85 | SETTING_ONLY_FAVORITES, default=False) | |
80 |
|
86 | |||
81 | get_notifications(context, settings_manager) |
|
87 | get_notifications(context, settings_manager, fav_tags) | |
82 | get_new_post_count(context, settings_manager) |
|
88 | get_new_post_count(context, settings_manager) | |
83 |
|
89 | |||
84 | return context |
|
90 | return context |
General Comments 0
You need to be logged in to leave comments.
Login now