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