Show More
@@ -1,114 +1,117 b'' | |||
|
1 | 1 | {% load i18n %} |
|
2 | 2 | {% load board %} |
|
3 | 3 | |
|
4 | 4 | {% get_current_language as LANGUAGE_CODE %} |
|
5 | 5 | |
|
6 | 6 | <div class="{{ css_class }}" id="{{ post.id }}" data-uid="{{ post.uid }}" {% if tree_depth %}style="margin-left: {{ tree_depth }}em;"{% endif %}> |
|
7 | 7 | <div class="post-info"> |
|
8 | 8 | <a class="post_id" href="{{ post.get_absolute_url }}">#{{ post.id }}</a> |
|
9 | 9 | <span class="title">{{ post.title }}</span> |
|
10 | {% if perms.boards.change_post %} | |
|
11 | <a href="{% url 'feed' %}?ip={{ post.poster_ip }}">*</a> | |
|
12 | {% endif %} | |
|
10 | 13 | <span class="pub_time" |
|
11 | 14 | {% if perms.boards.change_post %} |
|
12 | 15 | style="border-bottom: solid 2px #{{ post.get_ip_color }};" title="{{ post.poster_ip }}" |
|
13 | 16 | {% endif %} |
|
14 | 17 | ><time datetime="{{ post.pub_time|date:'c' }}">{{ post.pub_time }}</time></span> |
|
15 | 18 | {% if post.tripcode %} |
|
16 | 19 | / |
|
17 | 20 | {% with tripcode=post.get_tripcode %} |
|
18 | 21 | <a href="{% url 'feed' %}?tripcode={{ tripcode.get_full_text }}" |
|
19 | 22 | class="tripcode" title="{{ tripcode.get_full_text }}" |
|
20 | 23 | style="border: solid 2px #{{ tripcode.get_color }}; border-left: solid 1ex #{{ tripcode.get_color }};">{{ tripcode.get_short_text }}</a> |
|
21 | 24 | {% endwith %} |
|
22 | 25 | {% endif %} |
|
23 | 26 | {% comment %} |
|
24 | 27 | Thread death time needs to be shown only if the thread is alredy archived |
|
25 | 28 | and this is an opening post (thread death time) or a post for popup |
|
26 | 29 | (we don't see OP here so we show the death time in the post itself). |
|
27 | 30 | {% endcomment %} |
|
28 | 31 | {% if thread.is_archived %} |
|
29 | 32 | {% if is_opening %} |
|
30 | 33 | β <time datetime="{{ thread.bump_time|date:'c' }}">{{ thread.bump_time }}</time> |
|
31 | 34 | {% endif %} |
|
32 | 35 | {% endif %} |
|
33 | 36 | {% if is_opening %} |
|
34 | 37 | {% if need_open_link %} |
|
35 | 38 | {% if thread.is_archived %} |
|
36 | 39 | <a class="link" href="{% url 'thread' post.id %}">{% trans "Open" %}</a> |
|
37 | 40 | {% else %} |
|
38 | 41 | <a class="link" href="{% url 'thread' post.id %}#form">{% trans "Reply" %}</a> |
|
39 | 42 | {% endif %} |
|
40 | 43 | {% endif %} |
|
41 | 44 | {% else %} |
|
42 | 45 | {% if need_op_data %} |
|
43 | 46 | {% with thread.get_opening_post as op %} |
|
44 | 47 | {% trans " in " %}{{ op.get_link_view|safe }} <span class="title">{{ op.get_title_or_text }}</span> |
|
45 | 48 | {% endwith %} |
|
46 | 49 | {% endif %} |
|
47 | 50 | {% endif %} |
|
48 | 51 | {% if reply_link and not thread.is_archived %} |
|
49 | 52 | <a href="#form" onclick="addQuickReply('{{ post.id }}'); return false;">{% trans 'Reply' %}</a> |
|
50 | 53 | {% endif %} |
|
51 | 54 | |
|
52 | 55 | {% if perms.boards.change_post or perms.boards.delete_post or perms.boards.change_thread or perms_boards.delete_thread %} |
|
53 | 56 | <span class="moderator_info"> |
|
54 | 57 | {% if perms.boards.change_post or perms.boards.delete_post %} |
|
55 | 58 | | <a href="{% url 'admin:boards_post_change' post.id %}">{% trans 'Edit' %}</a> |
|
56 | 59 | {% endif %} |
|
57 | 60 | {% if perms.boards.change_thread or perms_boards.delete_thread %} |
|
58 | 61 | {% if is_opening %} |
|
59 | 62 | | <a href="{% url 'admin:boards_thread_change' thread.id %}">{% trans 'Edit thread' %}</a> |
|
60 | 63 | | <a href="{% url 'admin:boards_thread_delete' thread.id %}">{% trans 'Delete thread' %}</a> |
|
61 | 64 | {% else %} |
|
62 | 65 | | <a href="{% url 'admin:boards_post_delete' post.id %}">{% trans 'Delete post' %}</a> |
|
63 | 66 | {% endif %} |
|
64 | 67 | {% endif %} |
|
65 | 68 | {% if post.global_id_id %} |
|
66 | 69 | | <a href="{% url 'post_sync_data' post.id %}">RAW</a> |
|
67 | 70 | {% endif %} |
|
68 | 71 | </span> |
|
69 | 72 | {% endif %} |
|
70 | 73 | </div> |
|
71 | 74 | {% comment %} |
|
72 | 75 | Post images. Currently only 1 image can be posted and shown, but post model |
|
73 | 76 | supports multiple. |
|
74 | 77 | {% endcomment %} |
|
75 | 78 | {% for image in post.images.all %} |
|
76 | 79 | {{ image.get_view|safe }} |
|
77 | 80 | {% endfor %} |
|
78 | 81 | {% for file in post.attachments.all %} |
|
79 | 82 | {{ file.get_view|safe }} |
|
80 | 83 | {% endfor %} |
|
81 | 84 | {% comment %} |
|
82 | 85 | Post message (text) |
|
83 | 86 | {% endcomment %} |
|
84 | 87 | <div class="message"> |
|
85 | 88 | {% autoescape off %} |
|
86 | 89 | {% if truncated %} |
|
87 | 90 | {{ post.get_text|truncatewords_html:50 }} |
|
88 | 91 | {% else %} |
|
89 | 92 | {{ post.get_text }} |
|
90 | 93 | {% endif %} |
|
91 | 94 | {% endautoescape %} |
|
92 | 95 | </div> |
|
93 | 96 | {% if post.is_referenced %} |
|
94 | 97 | {% if not mode_tree %} |
|
95 | 98 | <div class="refmap"> |
|
96 | 99 | {% trans "Replies" %}: {{ post.refmap|safe }} |
|
97 | 100 | </div> |
|
98 | 101 | {% endif %} |
|
99 | 102 | {% endif %} |
|
100 | 103 | {% comment %} |
|
101 | 104 | Thread metadata: counters, tags etc |
|
102 | 105 | {% endcomment %} |
|
103 | 106 | {% if is_opening %} |
|
104 | 107 | <div class="metadata"> |
|
105 | 108 | {% if is_opening and need_open_link %} |
|
106 | 109 | β₯ {{ thread.get_reply_count }} |
|
107 | 110 | β {{ thread.get_images_count }} |
|
108 | 111 | {% endif %} |
|
109 | 112 | <span class="tags"> |
|
110 | 113 | {{ thread.get_tag_url_list|safe }} |
|
111 | 114 | </span> |
|
112 | 115 | </div> |
|
113 | 116 | {% endif %} |
|
114 | 117 | </div> |
@@ -1,70 +1,73 b'' | |||
|
1 | 1 | from django.core.urlresolvers import reverse |
|
2 | 2 | from django.shortcuts import render |
|
3 | 3 | |
|
4 | 4 | from boards.abstracts.paginator import get_paginator |
|
5 | 5 | from boards.abstracts.settingsmanager import get_settings_manager |
|
6 | 6 | from boards.models import Post |
|
7 | 7 | from boards.views.base import BaseBoardView |
|
8 | 8 | from boards.views.posting_mixin import PostMixin |
|
9 | 9 | |
|
10 | 10 | POSTS_PER_PAGE = 10 |
|
11 | 11 | |
|
12 | 12 | PARAMETER_CURRENT_PAGE = 'current_page' |
|
13 | 13 | PARAMETER_PAGINATOR = 'paginator' |
|
14 | 14 | PARAMETER_POSTS = 'posts' |
|
15 | 15 | |
|
16 | 16 | PARAMETER_PREV_LINK = 'prev_page_link' |
|
17 | 17 | PARAMETER_NEXT_LINK = 'next_page_link' |
|
18 | 18 | |
|
19 | 19 | TEMPLATE = 'boards/feed.html' |
|
20 | 20 | DEFAULT_PAGE = 1 |
|
21 | 21 | |
|
22 | 22 | |
|
23 | 23 | class FeedView(PostMixin, BaseBoardView): |
|
24 | 24 | |
|
25 | 25 | def get(self, request): |
|
26 | 26 | page = request.GET.get('page', DEFAULT_PAGE) |
|
27 | 27 | tripcode = request.GET.get('tripcode', None) |
|
28 | 28 | favorites = 'favorites' in request.GET |
|
29 | ip = request.GET.get('ip', None) | |
|
29 | 30 | |
|
30 | 31 | params = self.get_context_data(request=request) |
|
31 | 32 | |
|
32 | 33 | settings_manager = get_settings_manager(request) |
|
33 | 34 | |
|
34 | 35 | posts = Post.objects.exclude( |
|
35 | 36 | threads__tags__in=settings_manager.get_hidden_tags()).order_by( |
|
36 | 37 | '-pub_time').prefetch_related('attachments', 'thread', 'threads') |
|
37 | 38 | if tripcode: |
|
38 | 39 | posts = posts.filter(tripcode=tripcode) |
|
39 | 40 | if favorites: |
|
40 | 41 | fav_thread_ops = Post.objects.filter(id__in=settings_manager.get_fav_threads().keys()) |
|
41 | 42 | fav_threads = [op.get_thread() for op in fav_thread_ops] |
|
42 | 43 | posts = posts.filter(threads__in=fav_threads) |
|
44 | if ip and request.user.has_perm('post_delete'): | |
|
45 | posts = posts.filter(poster_ip=ip) | |
|
43 | 46 | |
|
44 | 47 | paginator = get_paginator(posts, POSTS_PER_PAGE) |
|
45 | 48 | paginator.current_page = int(page) |
|
46 | 49 | |
|
47 | 50 | params[PARAMETER_POSTS] = paginator.page(page).object_list |
|
48 | 51 | |
|
49 | 52 | paginator.set_url(reverse('feed'), request.GET.dict()) |
|
50 | 53 | |
|
51 | 54 | self.get_page_context(paginator, params, page) |
|
52 | 55 | |
|
53 | 56 | return render(request, TEMPLATE, params) |
|
54 | 57 | |
|
55 | 58 | # TODO Dedup this into PagedMixin |
|
56 | 59 | def get_page_context(self, paginator, params, page): |
|
57 | 60 | """ |
|
58 | 61 | Get pagination context variables |
|
59 | 62 | """ |
|
60 | 63 | |
|
61 | 64 | params[PARAMETER_PAGINATOR] = paginator |
|
62 | 65 | current_page = paginator.page(int(page)) |
|
63 | 66 | params[PARAMETER_CURRENT_PAGE] = current_page |
|
64 | 67 | if current_page.has_previous(): |
|
65 | 68 | params[PARAMETER_PREV_LINK] = paginator.get_page_url( |
|
66 | 69 | current_page.previous_page_number()) |
|
67 | 70 | if current_page.has_next(): |
|
68 | 71 | params[PARAMETER_NEXT_LINK] = paginator.get_page_url( |
|
69 | 72 | current_page.next_page_number()) |
|
70 | 73 |
General Comments 0
You need to be logged in to leave comments.
Login now