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