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