Show More
@@ -246,7 +246,9 b' class Post(models.Model):' | |||||
246 |
|
246 | |||
247 | def get_images_count(self): |
|
247 | def get_images_count(self): | |
248 | images_count = 1 if self.image else 0 |
|
248 | images_count = 1 if self.image else 0 | |
249 | for reply in self._get_replies(): |
|
249 | ||
|
250 | replies = self._get_replies() | |||
|
251 | for reply in replies: | |||
250 | if reply.image: |
|
252 | if reply.image: | |
251 | images_count += 1 |
|
253 | images_count += 1 | |
252 |
|
254 | |||
@@ -255,7 +257,7 b' class Post(models.Model):' | |||||
255 | def can_bump(self): |
|
257 | def can_bump(self): | |
256 | """Check if the thread can be bumped by replying""" |
|
258 | """Check if the thread can be bumped by replying""" | |
257 |
|
259 | |||
258 |
replies_count = |
|
260 | replies_count = self.get_reply_count() + 1 | |
259 |
|
261 | |||
260 | return replies_count <= settings.MAX_POSTS_PER_THREAD |
|
262 | return replies_count <= settings.MAX_POSTS_PER_THREAD | |
261 |
|
263 | |||
@@ -292,13 +294,8 b' class User(models.Model):' | |||||
292 | return setting |
|
294 | return setting | |
293 |
|
295 | |||
294 | def get_setting(self, name): |
|
296 | def get_setting(self, name): | |
295 |
|
|
297 | if Setting.objects.filter(name=name, user=self).exists(): | |
296 | if len(settings) > 0: |
|
298 | setting = Setting.objects.get(name=name, user=self) | |
297 | setting = settings[0] |
|
|||
298 | else: |
|
|||
299 | setting = None |
|
|||
300 |
|
||||
301 | if setting: |
|
|||
302 | setting_value = setting.value |
|
299 | setting_value = setting.value | |
303 | else: |
|
300 | else: | |
304 | setting_value = None |
|
301 | setting_value = None |
@@ -23,9 +23,9 b'' | |||||
23 | {% for thread in threads %} |
|
23 | {% for thread in threads %} | |
24 | <div class="thread"> |
|
24 | <div class="thread"> | |
25 | {% if thread.can_bump %} |
|
25 | {% if thread.can_bump %} | |
26 | <div class="post" id="{{thread.id}}"> |
|
26 | <div class="post" id="{{thread.id}}"> | |
27 | {% else %} |
|
27 | {% else %} | |
28 | <div class="post dead_post" id="{{ thread.id }}"> |
|
28 | <div class="post dead_post" id="{{ thread.id }}"> | |
29 | {% endif %} |
|
29 | {% endif %} | |
30 | {% if thread.image %} |
|
30 | {% if thread.image %} | |
31 | <div class="image"> |
|
31 | <div class="image"> | |
@@ -64,7 +64,7 b'' | |||||
64 | <div class="metadata"> |
|
64 | <div class="metadata"> | |
65 | {{ thread.get_reply_count }} {% trans 'replies' %}, |
|
65 | {{ thread.get_reply_count }} {% trans 'replies' %}, | |
66 | {{ thread.get_images_count }} {% trans 'images' %}. |
|
66 | {{ thread.get_images_count }} {% trans 'images' %}. | |
67 |
{% if thread.tags. |
|
67 | {% if thread.tags.exists %} | |
68 | <span class="tags">{% trans 'Tags' %}: |
|
68 | <span class="tags">{% trans 'Tags' %}: | |
69 | {% for tag in thread.tags.all %} |
|
69 | {% for tag in thread.tags.all %} | |
70 | <a class="tag" href=" |
|
70 | <a class="tag" href=" | |
@@ -79,9 +79,9 b'' | |||||
79 | <div class="last-replies"> |
|
79 | <div class="last-replies"> | |
80 | {% for post in thread.get_last_replies %} |
|
80 | {% for post in thread.get_last_replies %} | |
81 | {% if thread.can_bump %} |
|
81 | {% if thread.can_bump %} | |
82 | <div class="post" id="{{ post.id }}"> |
|
82 | <div class="post" id="{{ post.id }}"> | |
83 | {% else %} |
|
83 | {% else %} | |
84 |
<div class="post dead_post id="{{ post.id }}" |
|
84 | <div class="post dead_post id="{{ post.id }}"> | |
85 | {% endif %} |
|
85 | {% endif %} | |
86 | {% if post.image %} |
|
86 | {% if post.image %} | |
87 | <div class="image"> |
|
87 | <div class="image"> |
@@ -13,7 +13,7 b'' | |||||
13 | {% if posts %} |
|
13 | {% if posts %} | |
14 | <div id="posts"> |
|
14 | <div id="posts"> | |
15 | {% for post in posts %} |
|
15 | {% for post in posts %} | |
16 |
{% if |
|
16 | {% if bumpable %} | |
17 | <div class="post" id="{{ post.id }}"> |
|
17 | <div class="post" id="{{ post.id }}"> | |
18 | {% else %} |
|
18 | {% else %} | |
19 | <div class="post dead_post" id="{{ post.id }}"> |
|
19 | <div class="post dead_post" id="{{ post.id }}"> | |
@@ -53,7 +53,7 b'' | |||||
53 | {{ post.text.rendered }} |
|
53 | {{ post.text.rendered }} | |
54 | {% endautoescape %} |
|
54 | {% endautoescape %} | |
55 | </div> |
|
55 | </div> | |
56 |
{% if post. |
|
56 | {% if post.id == posts.0.id %} | |
57 | <div class="metadata"> |
|
57 | <div class="metadata"> | |
58 | <span class="tags">{% trans 'Tags' %}: |
|
58 | <span class="tags">{% trans 'Tags' %}: | |
59 | {% for tag in post.tags.all %} |
|
59 | {% for tag in post.tags.all %} |
@@ -148,6 +148,7 b' def thread(request, post_id):' | |||||
148 |
|
148 | |||
149 | context['posts'] = posts |
|
149 | context['posts'] = posts | |
150 | context['form'] = form |
|
150 | context['form'] = form | |
|
151 | context['bumpable'] = posts[0].can_bump() | |||
151 |
|
152 | |||
152 | return render(request, 'boards/thread.html', context) |
|
153 | return render(request, 'boards/thread.html', context) | |
153 |
|
154 |
General Comments 0
You need to be logged in to leave comments.
Login now