Show More
@@ -1,30 +1,31 b'' | |||
|
1 | 1 | {% extends 'boards/base.html' %} |
|
2 | 2 | |
|
3 | 3 | {% load board %} |
|
4 | 4 | {% load i18n %} |
|
5 | 5 | |
|
6 | 6 | {% block head %} |
|
7 | <meta name="robots" content="noindex"> | |
|
7 | 8 | <title>{{ site_name }} - {% trans 'Notifications' %} - {{ notification_username }}</title> |
|
8 | 9 | {% endblock %} |
|
9 | 10 | |
|
10 | 11 | {% block content %} |
|
11 | 12 | <div class="tag_info"><a href="{% url 'notifications' notification_username %}" class="user-cast">@{{ notification_username }}</a></div> |
|
12 | 13 | |
|
13 | 14 | {% if page %} |
|
14 | 15 | {% if page.has_previous %} |
|
15 | 16 | <div class="page_link"> |
|
16 | 17 | <a href="?page={{ page.previous_page_number }}">{% trans "Previous page" %}</a> |
|
17 | 18 | </div> |
|
18 | 19 | {% endif %} |
|
19 | 20 | |
|
20 | 21 | {% for post in page.object_list %} |
|
21 | 22 | {% post_view post %} |
|
22 | 23 | {% endfor %} |
|
23 | 24 | |
|
24 | 25 | {% if page.has_next %} |
|
25 | 26 | <div class="page_link"> |
|
26 | 27 | <a href="?page={{ page.next_page_number }}">{% trans "Next page" %}</a> |
|
27 | 28 | </div> |
|
28 | 29 | {% endif %} |
|
29 | 30 | {% endif %} |
|
30 | 31 | {% endblock %} |
@@ -1,188 +1,190 b'' | |||
|
1 | 1 | {% extends "boards/base.html" %} |
|
2 | 2 | |
|
3 | 3 | {% load i18n %} |
|
4 | 4 | {% load cache %} |
|
5 | 5 | {% load board %} |
|
6 | 6 | {% load static %} |
|
7 | 7 | |
|
8 | 8 | {% block head %} |
|
9 | <meta name="robots" content="noindex"> | |
|
10 | ||
|
9 | 11 | {% if tag %} |
|
10 | 12 | <title>{{ tag.name }} - {{ site_name }}</title> |
|
11 | 13 | {% else %} |
|
12 | 14 | <title>{{ site_name }}</title> |
|
13 | 15 | {% endif %} |
|
14 | 16 | |
|
15 | 17 | {% if current_page.has_previous %} |
|
16 | 18 | <link rel="prev" href=" |
|
17 | 19 | {% if tag %} |
|
18 | 20 | {% url "tag" tag_name=tag.name page=current_page.previous_page_number %} |
|
19 | 21 | {% else %} |
|
20 | 22 | {% url "index" page=current_page.previous_page_number %} |
|
21 | 23 | {% endif %} |
|
22 | 24 | " /> |
|
23 | 25 | {% endif %} |
|
24 | 26 | {% if current_page.has_next %} |
|
25 | 27 | <link rel="next" href=" |
|
26 | 28 | {% if tag %} |
|
27 | 29 | {% url "tag" tag_name=tag.name page=current_page.next_page_number %} |
|
28 | 30 | {% else %} |
|
29 | 31 | {% url "index" page=current_page.next_page_number %} |
|
30 | 32 | {% endif %} |
|
31 | 33 | " /> |
|
32 | 34 | {% endif %} |
|
33 | 35 | |
|
34 | 36 | {% endblock %} |
|
35 | 37 | |
|
36 | 38 | {% block content %} |
|
37 | 39 | |
|
38 | 40 | {% get_current_language as LANGUAGE_CODE %} |
|
39 | 41 | |
|
40 | 42 | {% if tag %} |
|
41 | 43 | <div class="tag_info"> |
|
42 | 44 | <h2> |
|
43 | 45 | <form action="{% url 'tag' tag.name %}" method="post" class="post-button-form"> |
|
44 | 46 | {% if is_favorite %} |
|
45 | 47 | <button name="method" value="unsubscribe" class="fav">β </button> |
|
46 | 48 | {% else %} |
|
47 | 49 | <button name="method" value="subscribe" class="not_fav">β </button> |
|
48 | 50 | {% endif %} |
|
49 | 51 | </form> |
|
50 | 52 | <form action="{% url 'tag' tag.name %}" method="post" class="post-button-form"> |
|
51 | 53 | {% if is_hidden %} |
|
52 | 54 | <button name="method" value="unhide" class="fav">H</button> |
|
53 | 55 | {% else %} |
|
54 | 56 | <button name="method" value="hide" class="not_fav">H</button> |
|
55 | 57 | {% endif %} |
|
56 | 58 | </form> |
|
57 | 59 | {% autoescape off %} |
|
58 | 60 | {{ tag.get_view }} |
|
59 | 61 | {% endautoescape %} |
|
60 | 62 | {% if moderator %} |
|
61 | 63 | <span class="moderator_info">[<a href="{% url 'admin:boards_tag_change' tag.id %}">{% trans 'Edit tag' %}</a>]</span> |
|
62 | 64 | {% endif %} |
|
63 | 65 | </h2> |
|
64 | 66 | <p>{% blocktrans with thread_count=tag.get_thread_count post_count=tag.get_post_count %}This tag has {{ thread_count }} threads and {{ post_count }} posts.{% endblocktrans %}</p> |
|
65 | 67 | </div> |
|
66 | 68 | {% endif %} |
|
67 | 69 | |
|
68 | 70 | {% if threads %} |
|
69 | 71 | {% if current_page.has_previous %} |
|
70 | 72 | <div class="page_link"> |
|
71 | 73 | <a href=" |
|
72 | 74 | {% if tag %} |
|
73 | 75 | {% url "tag" tag_name=tag.name page=current_page.previous_page_number %} |
|
74 | 76 | {% else %} |
|
75 | 77 | {% url "index" page=current_page.previous_page_number %} |
|
76 | 78 | {% endif %} |
|
77 | 79 | ">{% trans "Previous page" %}</a> |
|
78 | 80 | </div> |
|
79 | 81 | {% endif %} |
|
80 | 82 | |
|
81 | 83 | {% for thread in threads %} |
|
82 | 84 | {% cache 600 thread_short thread.id thread.last_edit_time moderator LANGUAGE_CODE %} |
|
83 | 85 | <div class="thread"> |
|
84 | 86 | {% post_view thread.get_opening_post moderator is_opening=True thread=thread truncated=True need_open_link=True %} |
|
85 | 87 | {% if not thread.archived %} |
|
86 | 88 | {% with last_replies=thread.get_last_replies %} |
|
87 | 89 | {% if last_replies %} |
|
88 | 90 | {% with skipped_replies_count=thread.get_skipped_replies_count %} |
|
89 | 91 | {% if skipped_replies_count %} |
|
90 | 92 | <div class="skipped_replies"> |
|
91 | 93 | <a href="{% url 'thread' thread.get_opening_post_id %}"> |
|
92 | 94 | {% blocktrans with count=skipped_replies_count %}Skipped {{ count }} replies. Open thread to see all replies.{% endblocktrans %} |
|
93 | 95 | </a> |
|
94 | 96 | </div> |
|
95 | 97 | {% endif %} |
|
96 | 98 | {% endwith %} |
|
97 | 99 | <div class="last-replies"> |
|
98 | 100 | {% for post in last_replies %} |
|
99 | 101 | {% post_view post is_opening=False moderator=moderator truncated=True %} |
|
100 | 102 | {% endfor %} |
|
101 | 103 | </div> |
|
102 | 104 | {% endif %} |
|
103 | 105 | {% endwith %} |
|
104 | 106 | {% endif %} |
|
105 | 107 | </div> |
|
106 | 108 | {% endcache %} |
|
107 | 109 | {% endfor %} |
|
108 | 110 | |
|
109 | 111 | {% if current_page.has_next %} |
|
110 | 112 | <div class="page_link"> |
|
111 | 113 | <a href=" |
|
112 | 114 | {% if tag %} |
|
113 | 115 | {% url "tag" tag_name=tag.name page=current_page.next_page_number %} |
|
114 | 116 | {% else %} |
|
115 | 117 | {% url "index" page=current_page.next_page_number %} |
|
116 | 118 | {% endif %} |
|
117 | 119 | ">{% trans "Next page" %}</a> |
|
118 | 120 | </div> |
|
119 | 121 | {% endif %} |
|
120 | 122 | {% else %} |
|
121 | 123 | <div class="post"> |
|
122 | 124 | {% trans 'No threads exist. Create the first one!' %}</div> |
|
123 | 125 | {% endif %} |
|
124 | 126 | |
|
125 | 127 | <div class="post-form-w"> |
|
126 | 128 | <script src="{% static 'js/panel.js' %}"></script> |
|
127 | 129 | <div class="post-form"> |
|
128 | 130 | <div class="form-title">{% trans "Create new thread" %}</div> |
|
129 | 131 | <div class="swappable-form-full"> |
|
130 | 132 | <form enctype="multipart/form-data" method="post" id="form">{% csrf_token %} |
|
131 | 133 | {{ form.as_div }} |
|
132 | 134 | <div class="form-submit"> |
|
133 | 135 | <input type="submit" value="{% trans "Post" %}"/> |
|
134 | 136 | </div> |
|
135 | 137 | (ctrl-enter) |
|
136 | 138 | </form> |
|
137 | 139 | </div> |
|
138 | 140 | <div> |
|
139 | 141 | {% trans 'Tags must be delimited by spaces. Text or image is required.' %} |
|
140 | 142 | </div> |
|
141 | 143 | <div><a href="{% url "staticpage" name="help" %}"> |
|
142 | 144 | {% trans 'Text syntax' %}</a></div> |
|
143 | 145 | </div> |
|
144 | 146 | </div> |
|
145 | 147 | |
|
146 | 148 | <script src="{% static 'js/form.js' %}"></script> |
|
147 | 149 | |
|
148 | 150 | {% endblock %} |
|
149 | 151 | |
|
150 | 152 | {% block metapanel %} |
|
151 | 153 | |
|
152 | 154 | <span class="metapanel"> |
|
153 | 155 | <b><a href="{% url "authors" %}">{{ site_name }}</a> {{ version }}</b> |
|
154 | 156 | {% trans "Pages:" %} |
|
155 | 157 | <a href=" |
|
156 | 158 | {% if tag %} |
|
157 | 159 | {% url "tag" tag_name=tag.name page=paginator.page_range|first %} |
|
158 | 160 | {% else %} |
|
159 | 161 | {% url "index" page=paginator.page_range|first %} |
|
160 | 162 | {% endif %} |
|
161 | 163 | "><<</a> |
|
162 | 164 | [ |
|
163 | 165 | {% for page in paginator.center_range %} |
|
164 | 166 | <a |
|
165 | 167 | {% ifequal page current_page.number %} |
|
166 | 168 | class="current_page" |
|
167 | 169 | {% endifequal %} |
|
168 | 170 | href=" |
|
169 | 171 | {% if tag %} |
|
170 | 172 | {% url "tag" tag_name=tag.name page=page %} |
|
171 | 173 | {% else %} |
|
172 | 174 | {% url "index" page=page %} |
|
173 | 175 | {% endif %} |
|
174 | 176 | ">{{ page }}</a> |
|
175 | 177 | {% if not forloop.last %},{% endif %} |
|
176 | 178 | {% endfor %} |
|
177 | 179 | ] |
|
178 | 180 | <a href=" |
|
179 | 181 | {% if tag %} |
|
180 | 182 | {% url "tag" tag_name=tag.name page=paginator.page_range|last %} |
|
181 | 183 | {% else %} |
|
182 | 184 | {% url "index" page=paginator.page_range|last %} |
|
183 | 185 | {% endif %} |
|
184 | 186 | ">>></a> |
|
185 | 187 | [<a href="rss/">RSS</a>] |
|
186 | 188 | </span> |
|
187 | 189 | |
|
188 | 190 | {% endblock %} |
@@ -1,42 +1,43 b'' | |||
|
1 | 1 | {% extends "boards/base.html" %} |
|
2 | 2 | |
|
3 | 3 | {% load i18n %} |
|
4 | 4 | {% load humanize %} |
|
5 | 5 | |
|
6 | 6 | {% block head %} |
|
7 | <meta name="robots" content="noindex"> | |
|
7 | 8 | <title>{% trans 'Settings' %} - {{ site_name }}</title> |
|
8 | 9 | {% endblock %} |
|
9 | 10 | |
|
10 | 11 | {% block content %} |
|
11 | 12 | |
|
12 | 13 | <div class="post"> |
|
13 | 14 | <p> |
|
14 | 15 | {% if moderator %} |
|
15 | 16 | {% trans 'You are moderator.' %} |
|
16 | 17 | {% endif %} |
|
17 | 18 | </p> |
|
18 | 19 | {% if hidden_tags %} |
|
19 | 20 | <p>{% trans 'Hidden tags:' %} |
|
20 | 21 | {% for tag in hidden_tags %} |
|
21 | 22 | {% autoescape off %} |
|
22 | 23 | {{ tag.get_view }} |
|
23 | 24 | {% endautoescape %} |
|
24 | 25 | {% endfor %} |
|
25 | 26 | </p> |
|
26 | 27 | {% else %} |
|
27 | 28 | <p>{% trans 'No hidden tags.' %}</p> |
|
28 | 29 | {% endif %} |
|
29 | 30 | </div> |
|
30 | 31 | |
|
31 | 32 | <div class="post-form-w"> |
|
32 | 33 | <div class="post-form"> |
|
33 | 34 | <form method="post">{% csrf_token %} |
|
34 | 35 | {{ form.as_div }} |
|
35 | 36 | <div class="form-submit"> |
|
36 | 37 | <input type="submit" value="{% trans "Save" %}" /> |
|
37 | 38 | </div> |
|
38 | 39 | </form> |
|
39 | 40 | </div> |
|
40 | 41 | </div> |
|
41 | 42 | |
|
42 | 43 | {% endblock %} |
@@ -1,68 +1,69 b'' | |||
|
1 | 1 | {% extends "boards/base.html" %} |
|
2 | 2 | |
|
3 | 3 | {% load i18n %} |
|
4 | 4 | {% load cache %} |
|
5 | 5 | {% load static from staticfiles %} |
|
6 | 6 | {% load board %} |
|
7 | 7 | |
|
8 | 8 | {% block head %} |
|
9 | <meta name="robots" content="noindex"> | |
|
9 | 10 | <title>{{ thread.get_opening_post.get_title|striptags|truncatewords:10 }} |
|
10 | 11 | - {{ site_name }}</title> |
|
11 | 12 | {% endblock %} |
|
12 | 13 | |
|
13 | 14 | {% block content %} |
|
14 | 15 | {% spaceless %} |
|
15 | 16 | {% get_current_language as LANGUAGE_CODE %} |
|
16 | 17 | |
|
17 | 18 | {% cache 600 thread_gallery_view thread.id thread.last_edit_time LANGUAGE_CODE request.get_host %} |
|
18 | 19 | <div class="image-mode-tab"> |
|
19 | 20 | <a href="{% url 'thread' thread.get_opening_post.id %}">{% trans 'Normal mode' %}</a>, |
|
20 | 21 | <a class="current_mode" href="{% url 'thread_gallery' thread.get_opening_post.id %}">{% trans 'Gallery mode' %}</a> |
|
21 | 22 | </div> |
|
22 | 23 | |
|
23 | 24 | <div id="posts-table"> |
|
24 | 25 | {% for post in posts %} |
|
25 | 26 | <div class="gallery_image"> |
|
26 | 27 | {% with post.get_first_image as image %} |
|
27 | 28 | <div> |
|
28 | 29 | <a |
|
29 | 30 | class="thumb" |
|
30 | 31 | href="{{ image.image.url }}"><img |
|
31 | 32 | src="{{ image.image.url_200x150 }}" |
|
32 | 33 | alt="{{ post.id }}" |
|
33 | 34 | width="{{ image.pre_width }}" |
|
34 | 35 | height="{{ image.pre_height }}" |
|
35 | 36 | data-width="{{ image.width }}" |
|
36 | 37 | data-height="{{ image.height }}"/> |
|
37 | 38 | </a> |
|
38 | 39 | </div> |
|
39 | 40 | <div class="gallery_image_metadata"> |
|
40 | 41 | {{ image.width }}x{{ image.height }} |
|
41 | 42 | {% image_actions image.image.url request.get_host %} |
|
42 | 43 | <br /> |
|
43 | 44 | <a href="{{ post.get_url }}">>>{{ post.id }}</a> |
|
44 | 45 | </div> |
|
45 | 46 | {% endwith %} |
|
46 | 47 | </div> |
|
47 | 48 | {% endfor %} |
|
48 | 49 | </div> |
|
49 | 50 | {% endcache %} |
|
50 | 51 | |
|
51 | 52 | {% endspaceless %} |
|
52 | 53 | {% endblock %} |
|
53 | 54 | |
|
54 | 55 | {% block metapanel %} |
|
55 | 56 | |
|
56 | 57 | {% get_current_language as LANGUAGE_CODE %} |
|
57 | 58 | |
|
58 | 59 | <span class="metapanel" data-last-update="{{ last_update }}"> |
|
59 | 60 | {% cache 600 thread_gallery_meta thread.last_edit_time moderator LANGUAGE_CODE %} |
|
60 | 61 | <span id="reply-count">{{ thread.get_reply_count }}</span>/{{ max_replies }} |
|
61 | 62 | {% trans 'messages' %}, |
|
62 | 63 | <span id="image-count">{{ thread.get_images_count }}</span> {% trans 'images' %}. |
|
63 | 64 | {% trans 'Last update: ' %}<time datetime="{{ thread.last_edit_time|date:'c' }}">{{ thread.last_edit_time|date:'r' }}</time> |
|
64 | 65 | [<a href="rss/">RSS</a>] |
|
65 | 66 | {% endcache %} |
|
66 | 67 | </span> |
|
67 | 68 | |
|
68 | 69 | {% endblock %} |
@@ -1,38 +1,42 b'' | |||
|
1 | 1 | {% extends 'boards/base.html' %} |
|
2 | 2 | |
|
3 | 3 | {% load board %} |
|
4 | 4 | {% load i18n %} |
|
5 | 5 | |
|
6 | {% block head %} | |
|
7 | <meta name="robots" content="noindex"> | |
|
8 | {% endblock %} | |
|
9 | ||
|
6 | 10 | {% block content %} |
|
7 | 11 | <div class="post-form-w"> |
|
8 | 12 | <div class="post-form"> |
|
9 | 13 | <h3>{% trans 'Search' %}</h3> |
|
10 | 14 | <form method="get" action=""> |
|
11 | 15 | {{ form.as_div }} |
|
12 | 16 | <div class="form-submit"> |
|
13 | 17 | <input type="submit" value="{% trans 'Search' %}"> |
|
14 | 18 | </div> |
|
15 | 19 | </form> |
|
16 | 20 | </div> |
|
17 | 21 | </div> |
|
18 | 22 | |
|
19 | 23 | {% if page %} |
|
20 | 24 | {% if page.has_previous %} |
|
21 | 25 | <div class="page_link"> |
|
22 | 26 | <a href="?query={{ query }}&page={{ page.previous_page_number }}">{% trans "Previous page" %} |
|
23 | 27 | </a> |
|
24 | 28 | </div> |
|
25 | 29 | {% endif %} |
|
26 | 30 | |
|
27 | 31 | {% for result in page.object_list %} |
|
28 | 32 | {{ result.object.get_search_view }} |
|
29 | 33 | {% endfor %} |
|
30 | 34 | |
|
31 | 35 | {% if page.has_next %} |
|
32 | 36 | <div class="page_link"> |
|
33 | 37 | <a href="?query={{ query }}&page={{ page.next_page_number }}">{% trans "Next page" %} |
|
34 | 38 | </a> |
|
35 | 39 | </div> |
|
36 | 40 | {% endif %} |
|
37 | 41 | {% endif %} |
|
38 | 42 | {% endblock %} |
@@ -1,133 +1,131 b'' | |||
|
1 | from django.core.urlresolvers import reverse | |
|
2 | 1 |
|
|
3 | from django.db import transaction | |
|
4 | 2 | from django.http import Http404 |
|
5 | 3 | from django.shortcuts import get_object_or_404, render, redirect |
|
6 | 4 | from django.views.generic.edit import FormMixin |
|
7 | 5 | |
|
8 | 6 | from boards import utils, settings |
|
9 | 7 | from boards.forms import PostForm, PlainErrorList |
|
10 |
from boards.models import Post |
|
|
11 | from boards.views.banned import BannedView | |
|
8 | from boards.models import Post | |
|
12 | 9 | from boards.views.base import BaseBoardView, CONTEXT_FORM |
|
13 | 10 | from boards.views.posting_mixin import PostMixin |
|
14 | 11 | import neboard |
|
15 | 12 | |
|
13 | ||
|
16 | 14 | TEMPLATE_GALLERY = 'boards/thread_gallery.html' |
|
17 | 15 | TEMPLATE_NORMAL = 'boards/thread.html' |
|
18 | 16 | |
|
19 | 17 | CONTEXT_POSTS = 'posts' |
|
20 | 18 | CONTEXT_OP = 'opening_post' |
|
21 | 19 | CONTEXT_BUMPLIMIT_PRG = 'bumplimit_progress' |
|
22 | 20 | CONTEXT_POSTS_LEFT = 'posts_left' |
|
23 | 21 | CONTEXT_LASTUPDATE = "last_update" |
|
24 | 22 | CONTEXT_MAX_REPLIES = 'max_replies' |
|
25 | 23 | CONTEXT_THREAD = 'thread' |
|
26 | 24 | CONTEXT_BUMPABLE = 'bumpable' |
|
27 | 25 | CONTEXT_WS_TOKEN = 'ws_token' |
|
28 | 26 | CONTEXT_WS_PROJECT = 'ws_project' |
|
29 | 27 | CONTEXT_WS_HOST = 'ws_host' |
|
30 | 28 | CONTEXT_WS_PORT = 'ws_port' |
|
31 | 29 | |
|
32 | 30 | FORM_TITLE = 'title' |
|
33 | 31 | FORM_TEXT = 'text' |
|
34 | 32 | FORM_IMAGE = 'image' |
|
35 | 33 | |
|
36 | 34 | |
|
37 | 35 | class ThreadView(BaseBoardView, PostMixin, FormMixin): |
|
38 | 36 | |
|
39 | 37 | def get(self, request, post_id, form: PostForm=None): |
|
40 | 38 | try: |
|
41 | 39 | opening_post = Post.objects.get(id=post_id) |
|
42 | 40 | except ObjectDoesNotExist: |
|
43 | 41 | raise Http404 |
|
44 | 42 | |
|
45 | 43 | # If this is not OP, don't show it as it is |
|
46 | 44 | if not opening_post.is_opening(): |
|
47 | 45 | return redirect(opening_post.get_thread().get_opening_post().get_url()) |
|
48 | 46 | |
|
49 | 47 | if not form: |
|
50 | 48 | form = PostForm(error_class=PlainErrorList) |
|
51 | 49 | |
|
52 | 50 | thread_to_show = opening_post.get_thread() |
|
53 | 51 | |
|
54 | 52 | params = dict() |
|
55 | 53 | |
|
56 | 54 | params[CONTEXT_FORM] = form |
|
57 | 55 | params[CONTEXT_LASTUPDATE] = str(utils.datetime_to_epoch( |
|
58 | 56 | thread_to_show.last_edit_time)) |
|
59 | 57 | params[CONTEXT_THREAD] = thread_to_show |
|
60 | 58 | params[CONTEXT_MAX_REPLIES] = settings.MAX_POSTS_PER_THREAD |
|
61 | 59 | |
|
62 | 60 | if settings.WEBSOCKETS_ENABLED: |
|
63 | 61 | params[CONTEXT_WS_TOKEN] = utils.get_websocket_token( |
|
64 | 62 | timestamp=params[CONTEXT_LASTUPDATE]) |
|
65 | 63 | params[CONTEXT_WS_PROJECT] = neboard.settings.CENTRIFUGE_PROJECT_ID |
|
66 | 64 | params[CONTEXT_WS_HOST] = request.get_host().split(':')[0] |
|
67 | 65 | params[CONTEXT_WS_PORT] = neboard.settings.CENTRIFUGE_PORT |
|
68 | 66 | |
|
69 | 67 | params.update(self.get_data(thread_to_show)) |
|
70 | 68 | |
|
71 | 69 | return render(request, self.get_template(), params) |
|
72 | 70 | |
|
73 | 71 | def post(self, request, post_id): |
|
74 | 72 | opening_post = get_object_or_404(Post, id=post_id) |
|
75 | 73 | |
|
76 | 74 | # If this is not OP, don't show it as it is |
|
77 | 75 | if not opening_post.is_opening(): |
|
78 | 76 | raise Http404 |
|
79 | 77 | |
|
80 | 78 | if not opening_post.get_thread().archived: |
|
81 | 79 | form = PostForm(request.POST, request.FILES, |
|
82 | 80 | error_class=PlainErrorList) |
|
83 | 81 | form.session = request.session |
|
84 | 82 | |
|
85 | 83 | if form.is_valid(): |
|
86 | 84 | return self.new_post(request, form, opening_post) |
|
87 | 85 | if form.need_to_ban: |
|
88 | 86 | # Ban user because he is suspected to be a bot |
|
89 | 87 | self._ban_current_user(request) |
|
90 | 88 | |
|
91 | 89 | return self.get(request, post_id, form) |
|
92 | 90 | |
|
93 | 91 | def new_post(self, request, form: PostForm, opening_post: Post=None, |
|
94 | 92 | html_response=True): |
|
95 | 93 | """ |
|
96 | 94 | Adds a new post (in thread or as a reply). |
|
97 | 95 | """ |
|
98 | 96 | |
|
99 | 97 | ip = utils.get_client_ip(request) |
|
100 | 98 | |
|
101 | 99 | data = form.cleaned_data |
|
102 | 100 | |
|
103 | 101 | title = data[FORM_TITLE] |
|
104 | 102 | text = data[FORM_TEXT] |
|
105 | 103 | image = form.get_image() |
|
106 | 104 | |
|
107 | 105 | text = self._remove_invalid_links(text) |
|
108 | 106 | |
|
109 | 107 | post_thread = opening_post.get_thread() |
|
110 | 108 | |
|
111 | 109 | post = Post.objects.create_post(title=title, text=text, image=image, |
|
112 | 110 | thread=post_thread, ip=ip) |
|
113 | 111 | post.send_to_websocket(request) |
|
114 | 112 | |
|
115 | 113 | if html_response: |
|
116 | 114 | if opening_post: |
|
117 | 115 | return redirect(post.get_url()) |
|
118 | 116 | else: |
|
119 | 117 | return post |
|
120 | 118 | |
|
121 | 119 | def get_data(self, thread): |
|
122 | 120 | """ |
|
123 | 121 | Returns context params for the view. |
|
124 | 122 | """ |
|
125 | 123 | |
|
126 | 124 | pass |
|
127 | 125 | |
|
128 | 126 | def get_template(self): |
|
129 | 127 | """ |
|
130 | 128 | Gets template to show the thread mode on. |
|
131 | 129 | """ |
|
132 | 130 | |
|
133 | 131 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now