Show More
@@ -1,79 +1,88 b'' | |||||
1 | from boards.abstracts.settingsmanager import get_settings_manager, \ |
|
1 | from boards.abstracts.settingsmanager import get_settings_manager, \ | |
2 | SETTING_USERNAME, SETTING_LAST_NOTIFICATION_ID, SETTING_IMAGE_VIEWER |
|
2 | SETTING_USERNAME, SETTING_LAST_NOTIFICATION_ID, SETTING_IMAGE_VIEWER | |
3 | from boards.models.user import Notification |
|
3 | from boards.models.user import Notification | |
4 |
|
4 | |||
5 | __author__ = 'neko259' |
|
5 | __author__ = 'neko259' | |
6 |
|
6 | |||
7 | from boards import settings, utils |
|
7 | from boards import settings, utils | |
8 | from boards.models import Post, Tag |
|
8 | from boards.models import Post, Tag | |
9 |
|
9 | |||
10 | CONTEXT_SITE_NAME = 'site_name' |
|
10 | CONTEXT_SITE_NAME = 'site_name' | |
11 | CONTEXT_VERSION = 'version' |
|
11 | CONTEXT_VERSION = 'version' | |
12 | CONTEXT_MODERATOR = 'moderator' |
|
12 | CONTEXT_MODERATOR = 'moderator' | |
13 | CONTEXT_THEME_CSS = 'theme_css' |
|
13 | CONTEXT_THEME_CSS = 'theme_css' | |
14 | CONTEXT_THEME = 'theme' |
|
14 | CONTEXT_THEME = 'theme' | |
15 | CONTEXT_PPD = 'posts_per_day' |
|
15 | CONTEXT_PPD = 'posts_per_day' | |
16 | CONTEXT_TAGS = 'tags' |
|
16 | CONTEXT_TAGS = 'tags' | |
17 | CONTEXT_USER = 'user' |
|
17 | CONTEXT_USER = 'user' | |
18 | CONTEXT_NEW_NOTIFICATIONS_COUNT = 'new_notifications_count' |
|
18 | CONTEXT_NEW_NOTIFICATIONS_COUNT = 'new_notifications_count' | |
19 | CONTEXT_USERNAME = 'username' |
|
19 | CONTEXT_USERNAME = 'username' | |
20 | CONTEXT_TAGS_STR = 'tags_str' |
|
20 | CONTEXT_TAGS_STR = 'tags_str' | |
21 | CONTEXT_IMAGE_VIEWER = 'image_viewer' |
|
21 | CONTEXT_IMAGE_VIEWER = 'image_viewer' | |
22 | CONTEXT_FAV_THREADS = 'fav_threads' |
|
22 | CONTEXT_FAV_THREADS = 'fav_threads' | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | def get_notifications(context, request): |
|
25 | def get_notifications(context, request): | |
26 | settings_manager = get_settings_manager(request) |
|
26 | settings_manager = get_settings_manager(request) | |
27 | username = settings_manager.get_setting(SETTING_USERNAME) |
|
27 | username = settings_manager.get_setting(SETTING_USERNAME) | |
28 | new_notifications_count = 0 |
|
28 | new_notifications_count = 0 | |
29 | if username is not None and len(username) > 0: |
|
29 | if username is not None and len(username) > 0: | |
30 | last_notification_id = settings_manager.get_setting( |
|
30 | last_notification_id = settings_manager.get_setting( | |
31 | SETTING_LAST_NOTIFICATION_ID) |
|
31 | SETTING_LAST_NOTIFICATION_ID) | |
32 |
|
32 | |||
33 | new_notifications_count = Notification.objects.get_notification_posts( |
|
33 | new_notifications_count = Notification.objects.get_notification_posts( | |
34 | username=username, last=last_notification_id).count() |
|
34 | username=username, last=last_notification_id).count() | |
35 | context[CONTEXT_NEW_NOTIFICATIONS_COUNT] = new_notifications_count |
|
35 | context[CONTEXT_NEW_NOTIFICATIONS_COUNT] = new_notifications_count | |
36 | context[CONTEXT_USERNAME] = username |
|
36 | context[CONTEXT_USERNAME] = username | |
37 |
|
37 | |||
38 |
|
38 | |||
39 | def user_and_ui_processor(request): |
|
39 | def user_and_ui_processor(request): | |
40 | context = dict() |
|
40 | context = dict() | |
41 |
|
41 | |||
42 | context[CONTEXT_PPD] = float(Post.objects.get_posts_per_day()) |
|
42 | context[CONTEXT_PPD] = float(Post.objects.get_posts_per_day()) | |
43 |
|
43 | |||
44 | settings_manager = get_settings_manager(request) |
|
44 | settings_manager = get_settings_manager(request) | |
45 | fav_tags = settings_manager.get_fav_tags() |
|
45 | fav_tags = settings_manager.get_fav_tags() | |
46 | context[CONTEXT_TAGS] = fav_tags |
|
46 | context[CONTEXT_TAGS] = fav_tags | |
47 |
|
47 | |||
48 | _get_fav_threads(context, settings_manager) |
|
48 | _get_fav_threads(context, settings_manager) | |
49 |
|
49 | |||
50 | context[CONTEXT_TAGS_STR] = Tag.objects.get_tag_url_list(fav_tags) |
|
50 | context[CONTEXT_TAGS_STR] = Tag.objects.get_tag_url_list(fav_tags) | |
51 | theme = settings_manager.get_theme() |
|
51 | theme = settings_manager.get_theme() | |
52 | context[CONTEXT_THEME] = theme |
|
52 | context[CONTEXT_THEME] = theme | |
53 | context[CONTEXT_THEME_CSS] = 'css/' + theme + '/base_page.css' |
|
53 | context[CONTEXT_THEME_CSS] = 'css/' + theme + '/base_page.css' | |
54 |
|
54 | |||
55 | # This shows the moderator panel |
|
55 | # This shows the moderator panel | |
56 | context[CONTEXT_MODERATOR] = utils.is_moderator(request) |
|
56 | context[CONTEXT_MODERATOR] = utils.is_moderator(request) | |
57 |
|
57 | |||
58 | context[CONTEXT_VERSION] = settings.get('Version', 'Version') |
|
58 | context[CONTEXT_VERSION] = settings.get('Version', 'Version') | |
59 | context[CONTEXT_SITE_NAME] = settings.get('Version', 'SiteName') |
|
59 | context[CONTEXT_SITE_NAME] = settings.get('Version', 'SiteName') | |
60 |
|
60 | |||
61 | context[CONTEXT_IMAGE_VIEWER] = settings_manager.get_setting( |
|
61 | context[CONTEXT_IMAGE_VIEWER] = settings_manager.get_setting( | |
62 | SETTING_IMAGE_VIEWER, |
|
62 | SETTING_IMAGE_VIEWER, | |
63 | default=settings.get('View', 'DefaultImageViewer')) |
|
63 | default=settings.get('View', 'DefaultImageViewer')) | |
64 |
|
64 | |||
65 | get_notifications(context, request) |
|
65 | get_notifications(context, request) | |
66 |
|
66 | |||
67 | return context |
|
67 | return context | |
68 |
|
68 | |||
69 |
|
69 | |||
70 | def _get_fav_threads(context, settings_manager): |
|
70 | def _get_fav_threads(context, settings_manager): | |
71 | fav_threads_setting = settings_manager.get_fav_threads() |
|
71 | fav_threads_setting = settings_manager.get_fav_threads() | |
72 | if fav_threads_setting: |
|
72 | if fav_threads_setting: | |
73 | fav_threads = Post.objects.filter( |
|
73 | fav_threads = Post.objects.filter( | |
74 | id__in=fav_threads_setting.keys()).only('url', 'id', 'thread')\ |
|
74 | id__in=fav_threads_setting.keys()).only('url', 'id', 'thread')\ | |
75 | .select_related('thread') |
|
75 | .select_related('thread') | |
76 | context[CONTEXT_FAV_THREADS] = [ |
|
76 | ||
77 | (post, post.get_thread().get_replies_newer( |
|
77 | context_thread_list = [] | |
78 | fav_threads_setting[str(post.id)]).count()) |
|
78 | for post in fav_threads: | |
79 | for post in fav_threads] |
|
79 | new_replies = post.get_thread().get_replies_newer(fav_threads_setting[str(post.id)]) | |
|
80 | ||||
|
81 | element = dict() | |||
|
82 | element['post'] = post | |||
|
83 | element['count'] = new_replies.count() | |||
|
84 | if element['count'] > 0: | |||
|
85 | element['new_post'] = new_replies.first().get_absolute_url() | |||
|
86 | context_thread_list.append(element) | |||
|
87 | context[CONTEXT_FAV_THREADS] = context_thread_list | |||
|
88 |
@@ -1,86 +1,86 b'' | |||||
1 | {% load staticfiles %} |
|
1 | {% load staticfiles %} | |
2 | {% load i18n %} |
|
2 | {% load i18n %} | |
3 | {% load l10n %} |
|
3 | {% load l10n %} | |
4 | {% load static from staticfiles %} |
|
4 | {% load static from staticfiles %} | |
5 |
|
5 | |||
6 | <!DOCTYPE html> |
|
6 | <!DOCTYPE html> | |
7 | <html> |
|
7 | <html> | |
8 | <head> |
|
8 | <head> | |
9 | <link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}" media="all"/> |
|
9 | <link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}" media="all"/> | |
10 | <link rel="stylesheet" type="text/css" href="{% static 'css/3party/highlight.css' %}" media="all"/> |
|
10 | <link rel="stylesheet" type="text/css" href="{% static 'css/3party/highlight.css' %}" media="all"/> | |
11 | <link rel="stylesheet" type="text/css" href="{% static 'css/3party/jquery-ui.min.css' %}" media="all"/> |
|
11 | <link rel="stylesheet" type="text/css" href="{% static 'css/3party/jquery-ui.min.css' %}" media="all"/> | |
12 | <link rel="stylesheet" type="text/css" href="{% static theme_css %}" media="all"/> |
|
12 | <link rel="stylesheet" type="text/css" href="{% static theme_css %}" media="all"/> | |
13 |
|
13 | |||
14 | <link rel="alternate" type="application/rss+xml" href="rss/" title="{% trans 'Feed' %}"/> |
|
14 | <link rel="alternate" type="application/rss+xml" href="rss/" title="{% trans 'Feed' %}"/> | |
15 |
|
15 | |||
16 | <link rel="icon" type="image/png" |
|
16 | <link rel="icon" type="image/png" | |
17 | href="{% static 'favicon.png' %}"> |
|
17 | href="{% static 'favicon.png' %}"> | |
18 |
|
18 | |||
19 | <meta name="viewport" content="width=device-width, initial-scale=1"/> |
|
19 | <meta name="viewport" content="width=device-width, initial-scale=1"/> | |
20 | <meta charset="utf-8"/> |
|
20 | <meta charset="utf-8"/> | |
21 |
|
21 | |||
22 | {% block head %}{% endblock %} |
|
22 | {% block head %}{% endblock %} | |
23 | </head> |
|
23 | </head> | |
24 | <body data-image-viewer="{{ image_viewer }}"> |
|
24 | <body data-image-viewer="{{ image_viewer }}"> | |
25 | <script src="{% static 'js/jquery-2.0.1.min.js' %}"></script> |
|
25 | <script src="{% static 'js/jquery-2.0.1.min.js' %}"></script> | |
26 | <script src="{% static 'js/3party/jquery-ui.min.js' %}"></script> |
|
26 | <script src="{% static 'js/3party/jquery-ui.min.js' %}"></script> | |
27 | <script src="{% static 'js/jquery.mousewheel.js' %}"></script> |
|
27 | <script src="{% static 'js/jquery.mousewheel.js' %}"></script> | |
28 | <script src="{% url 'js_info_dict' %}"></script> |
|
28 | <script src="{% url 'js_info_dict' %}"></script> | |
29 |
|
29 | |||
30 | <div class="navigation_panel header"> |
|
30 | <div class="navigation_panel header"> | |
31 | <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a> |
|
31 | <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a> | |
32 | {% if tags_str %} |
|
32 | {% if tags_str %} | |
33 | {% autoescape off %} |
|
33 | {% autoescape off %} | |
34 | {{ tags_str }}, |
|
34 | {{ tags_str }}, | |
35 | {% endautoescape %} |
|
35 | {% endautoescape %} | |
36 | {% else %} |
|
36 | {% else %} | |
37 | {% trans 'Add tags' %} → |
|
37 | {% trans 'Add tags' %} → | |
38 | {% endif %} |
|
38 | {% endif %} | |
39 | <a href="{% url 'tags' 'required'%}" title="{% trans 'Tag management' %}">{% trans "tags" %}</a>, |
|
39 | <a href="{% url 'tags' 'required'%}" title="{% trans 'Tag management' %}">{% trans "tags" %}</a>, | |
40 | <a href="{% url 'search' %}" title="{% trans 'Search' %}">{% trans 'search' %}</a>, |
|
40 | <a href="{% url 'search' %}" title="{% trans 'Search' %}">{% trans 'search' %}</a>, | |
41 | <a href="{% url 'feed' %}" title="{% trans 'Feed' %}">{% trans 'feed' %}</a>, |
|
41 | <a href="{% url 'feed' %}" title="{% trans 'Feed' %}">{% trans 'feed' %}</a>, | |
42 | <a href="{% url 'random' %}" title="{% trans 'Random images' %}">{% trans 'random' %}</a> |
|
42 | <a href="{% url 'random' %}" title="{% trans 'Random images' %}">{% trans 'random' %}</a> | |
43 |
|
43 | |||
44 | {% if username %} |
|
44 | {% if username %} | |
45 | <a class="right-link link" href="{% url 'notifications' username %}" title="{% trans 'Notifications' %}"> |
|
45 | <a class="right-link link" href="{% url 'notifications' username %}" title="{% trans 'Notifications' %}"> | |
46 | {% trans 'Notifications' %} |
|
46 | {% trans 'Notifications' %} | |
47 | {% ifnotequal new_notifications_count 0 %} |
|
47 | {% ifnotequal new_notifications_count 0 %} | |
48 | (<b>{{ new_notifications_count }}</b>) |
|
48 | (<b>{{ new_notifications_count }}</b>) | |
49 | {% endifnotequal %} |
|
49 | {% endifnotequal %} | |
50 | </a> |
|
50 | </a> | |
51 | {% endif %} |
|
51 | {% endif %} | |
52 |
|
52 | |||
53 | <a class="right-link link" href="{% url 'settings' %}">{% trans 'Settings' %}</a> |
|
53 | <a class="right-link link" href="{% url 'settings' %}">{% trans 'Settings' %}</a> | |
54 | </div> |
|
54 | </div> | |
55 |
|
55 | |||
56 | {% if fav_threads %} |
|
56 | {% if fav_threads %} | |
57 | <div class="image-mode-tab"> |
|
57 | <div class="image-mode-tab"> | |
58 | ★ |
|
58 | ★ | |
59 | {% for thread in fav_threads %} |
|
59 | {% for thread in fav_threads %} | |
60 | {% comment %} |
|
60 | {% comment %} | |
61 | If there are new posts in the thread, show their count. |
|
61 | If there are new posts in the thread, show their count. | |
62 | {% endcomment %} |
|
62 | {% endcomment %} | |
63 |
{{ thread. |
|
63 | {{ thread.post.get_link_view|safe }}{% if thread.count %} (<a href="{{ thread.new_post }}">+{{ thread.count }}</a>){% endif %}{% if not forloop.last %}, {% endif %} | |
64 | {% endfor %} |
|
64 | {% endfor %} | |
65 | </div> |
|
65 | </div> | |
66 | {% endif %} |
|
66 | {% endif %} | |
67 |
|
67 | |||
68 | {% block content %}{% endblock %} |
|
68 | {% block content %}{% endblock %} | |
69 |
|
69 | |||
70 | <script src="{% static 'js/3party/highlight.min.js' %}"></script> |
|
70 | <script src="{% static 'js/3party/highlight.min.js' %}"></script> | |
71 | <script src="{% static 'js/popup.js' %}"></script> |
|
71 | <script src="{% static 'js/popup.js' %}"></script> | |
72 | <script src="{% static 'js/image.js' %}"></script> |
|
72 | <script src="{% static 'js/image.js' %}"></script> | |
73 | <script src="{% static 'js/refpopup.js' %}"></script> |
|
73 | <script src="{% static 'js/refpopup.js' %}"></script> | |
74 | <script src="{% static 'js/main.js' %}"></script> |
|
74 | <script src="{% static 'js/main.js' %}"></script> | |
75 |
|
75 | |||
76 | <div class="navigation_panel footer"> |
|
76 | <div class="navigation_panel footer"> | |
77 | {% block metapanel %}{% endblock %} |
|
77 | {% block metapanel %}{% endblock %} | |
78 | [<a href="{% url 'admin:index' %}">{% trans 'Admin' %}</a>] |
|
78 | [<a href="{% url 'admin:index' %}">{% trans 'Admin' %}</a>] | |
79 | {% with ppd=posts_per_day|floatformat:2 %} |
|
79 | {% with ppd=posts_per_day|floatformat:2 %} | |
80 | {% blocktrans %}Speed: {{ ppd }} posts per day{% endblocktrans %} |
|
80 | {% blocktrans %}Speed: {{ ppd }} posts per day{% endblocktrans %} | |
81 | {% endwith %} |
|
81 | {% endwith %} | |
82 | <a class="link" href="#top" id="up">{% trans 'Up' %}</a> |
|
82 | <a class="link" href="#top" id="up">{% trans 'Up' %}</a> | |
83 | </div> |
|
83 | </div> | |
84 |
|
84 | |||
85 | </body> |
|
85 | </body> | |
86 | </html> |
|
86 | </html> |
General Comments 0
You need to be logged in to leave comments.
Login now