##// END OF EJS Templates
Optimized threads list.
neko259 -
r163:e0408178 default
parent child Browse files
Show More
@@ -77,7 +77,7 b' class PostManager(models.Manager):'
77 threads = threads.order_by(order_by)
77 threads = threads.order_by(order_by)
78
78
79 if page != ALL_PAGES:
79 if page != ALL_PAGES:
80 thread_count = len(threads)
80 thread_count = threads.count()
81
81
82 if page < self.get_thread_page_count(tag=tag):
82 if page < self.get_thread_page_count(tag=tag):
83 start_thread = page * settings.THREADS_PER_PAGE
83 start_thread = page * settings.THREADS_PER_PAGE
@@ -22,51 +22,51 b''
22 {% if threads %}
22 {% if threads %}
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.bumpable %}
26 <div class="post" id="{{thread.id}}">
26 <div class="post" id="{{ thread.thread.id }}">
27 {% else %}
27 {% else %}
28 <div class="post dead_post" id="{{ thread.id }}">
28 <div class="post dead_post" id="{{ thread.thread.id }}">
29 {% endif %}
29 {% endif %}
30 {% if thread.image %}
30 {% if thread.thread.image %}
31 <div class="image">
31 <div class="image">
32 <a class="fancy"
32 <a class="fancy"
33 href="{{ thread.image.url }}"><img
33 href="{{ thread.thread.image.url }}"><img
34 src="{{ thread.image.url_200x150 }}"
34 src="{{ thread.thread.image.url_200x150 }}"
35 alt="{% trans 'Post image' %}"
35 alt="{% trans 'Post image' %}"
36 data-width="{{ thread.image_width }}"
36 data-width="{{ thread.thread.image_width }}"
37 data-height="{{ thread.image_height }}" />
37 data-height="{{ thread.thread.image_height }}" />
38 </a>
38 </a>
39 </div>
39 </div>
40 {% endif %}
40 {% endif %}
41 <div class="message">
41 <div class="message">
42 <div class="post-info">
42 <div class="post-info">
43 <span class="title">{{ thread.title }}</span>
43 <span class="title">{{ thread.thread.title }}</span>
44 <a class="post_id" href="{% url 'thread' thread.id %}"
44 <a class="post_id" href="{% url 'thread' thread.thread.id %}"
45 >(#{{ thread.id }})</a>
45 >(#{{ thread.thread.id }})</a>
46 [{{ thread.pub_time }}]
46 [{{ thread.thread.pub_time }}]
47 [<a class="link" href="{% url 'thread' thread.id %}#form"
47 [<a class="link" href="{% url 'thread' thread.thread.id %}#form"
48 >{% trans "Reply" %}</a>]
48 >{% trans "Reply" %}</a>]
49
49
50 {% if user.is_moderator %}
50 {% if user.is_moderator %}
51 <span class="moderator_info">
51 <span class="moderator_info">
52 [<a href="{% url 'delete' post_id=thread.id %}?next={{ request.path }}"
52 [<a href="{% url 'delete' post_id=thread.thread.id %}?next={{ request.path }}"
53 >{% trans 'Delete' %}</a>]
53 >{% trans 'Delete' %}</a>]
54 ({{ thread.poster_ip }})
54 ({{ thread.thread.poster_ip }})
55 [<a href="{% url 'ban' post_id=thread.id %}?next={{ request.path }}"
55 [<a href="{% url 'ban' post_id=thread.thread.id %}?next={{ request.path }}"
56 >{% trans 'Ban IP' %}</a>]
56 >{% trans 'Ban IP' %}</a>]
57 </span>
57 </span>
58 {% endif %}
58 {% endif %}
59 </div>
59 </div>
60 {% autoescape off %}
60 {% autoescape off %}
61 {{ thread.text.rendered|truncatewords_html:50 }}
61 {{ thread.thread.text.rendered|truncatewords_html:50 }}
62 {% endautoescape %}
62 {% endautoescape %}
63 </div>
63 </div>
64 <div class="metadata">
64 <div class="metadata">
65 {{ thread.get_reply_count }} {% trans 'replies' %},
65 {{ thread.thread.get_reply_count }} {% trans 'replies' %},
66 {{ thread.get_images_count }} {% trans 'images' %}.
66 {{ thread.thread.get_images_count }} {% trans 'images' %}.
67 {% if thread.tags.exists %}
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.thread.tags.all %}
70 <a class="tag" href="
70 <a class="tag" href="
71 {% url 'tag' tag_name=tag.name %}">
71 {% url 'tag' tag_name=tag.name %}">
72 {{ tag.name }}</a>
72 {{ tag.name }}</a>
@@ -75,13 +75,13 b''
75 {% endif %}
75 {% endif %}
76 </div>
76 </div>
77 </div>
77 </div>
78 {% if thread.get_last_replies %}
78 {% if thread.thread.get_last_replies %}
79 <div class="last-replies">
79 <div class="last-replies">
80 {% for post in thread.get_last_replies %}
80 {% for post in thread.thread.get_last_replies %}
81 {% if thread.can_bump %}
81 {% if thread.bumpable %}
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">
@@ -98,7 +98,7 b''
98 <div class="post-info">
98 <div class="post-info">
99 <span class="title">{{ post.title }}</span>
99 <span class="title">{{ post.title }}</span>
100 <a class="post_id" href="
100 <a class="post_id" href="
101 {% url 'thread' thread.id %}#{{ post.id }}">
101 {% url 'thread' thread.thread.id %}#{{ post.id }}">
102 (#{{ post.id }})</a>
102 (#{{ post.id }})</a>
103 [{{ post.pub_time }}]
103 [{{ post.pub_time }}]
104 </div>
104 </div>
@@ -36,7 +36,10 b' def index(request, page=0):'
36 else:
36 else:
37 form = threadFormClass(error_class=PlainErrorList, **kwargs)
37 form = threadFormClass(error_class=PlainErrorList, **kwargs)
38
38
39 threads = Post.objects.get_threads(page=int(page))
39 threads = []
40 for thread in Post.objects.get_threads(page=int(page)):
41 threads.append({'thread': thread,
42 'bumpable': thread.can_bump()})
40
43
41 context['threads'] = None if len(threads) == 0 else threads
44 context['threads'] = None if len(threads) == 0 else threads
42 context['form'] = form
45 context['form'] = form
General Comments 0
You need to be logged in to leave comments. Login now