##// END OF EJS Templates
Added thread metadata (replies, images, gets) to the threads list.
neko259 -
r30:0d6932e0 default
parent child Browse files
Show More
@@ -132,6 +132,34 b' class Post(models.Model):'
132 132 def __unicode__(self):
133 133 return self.title + ' (' + self.text + ')'
134 134
135 def _get_replies(self):
136 return Post.objects.filter(parent=self.id)
137
138 def get_reply_count(self):
139 return len(self._get_replies())
140
141 def get_images_count(self):
142 images_count = 1 if self.image else 0
143 for reply in self._get_replies():
144 if reply.image:
145 images_count += 1
146
147 return images_count
148
149 def get_gets_count(self):
150 gets_count = 1 if self.is_get() else 0
151 for reply in self._get_replies():
152 if reply.is_get():
153 gets_count += 1
154
155 return gets_count
156
157 def is_get(self):
158 """If the post has pretty id (1, 1000, 77777), than it is called GET"""
159
160 # TODO Make a better algorithm for describing gets
161 return self.id == 1 or self.id % 10 == 0
162
135 163
136 164 class Admin(models.Model):
137 165 """
@@ -31,11 +31,11 b' html {'
31 31 }
32 32
33 33 .link {
34 color: #829dba;
34 color: #afdcec;
35 35 }
36 36
37 37 .link:hover {
38 color: #ba9f82;
38 color: #fff380;
39 39 }
40 40
41 41 .post_id {
@@ -68,4 +68,12 b' html {'
68 68
69 69 .form-title {
70 70 font-weight: bolder;
71 }
72
73 .metadata {
74 background: #666;
75 padding: 10px;
76 border-radius: 5px;
77 float: left;
78 margin-top: 5px;
71 79 } No newline at end of file
@@ -3,42 +3,58 b''
3 3 # This file is distributed under the same license as the PACKAGE package.
4 4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 5 #
6 #, fuzzy
7 6 msgid ""
8 7 msgstr ""
9 8 "Project-Id-Version: PACKAGE VERSION\n"
10 9 "Report-Msgid-Bugs-To: \n"
11 "POT-Creation-Date: 2013-04-05 20:55+0300\n"
10 "POT-Creation-Date: 2013-04-11 21:26+0300\n"
12 11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13 12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14 13 "Language-Team: LANGUAGE <LL@li.org>\n"
15 "Language: \n"
14 "Language: ru\n"
16 15 "MIME-Version: 1.0\n"
17 16 "Content-Type: text/plain; charset=UTF-8\n"
18 17 "Content-Transfer-Encoding: 8bit\n"
19 18 "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
20 19 "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
21 20
21 #: templates/posting_general.html:22
22 msgid "View"
23 msgstr "Просмотр"
24
25 #: templates/posting_general.html:25
26 msgid "replies"
27 msgstr "ответов"
28
29 #: templates/posting_general.html:26
30 msgid "images"
31 msgstr "изображений"
32
33 #: templates/posting_general.html:29 templates/posting_general.html.py:61
34 #: templates/thread.html:23
35 msgid "Tags"
36 msgstr "Теги"
37
38 #: templates/posting_general.html:46
39 msgid "Create new thread"
40 msgstr "Создать новый тред"
41
42 #: templates/posting_general.html:49 templates/thread.html:42
22 43 msgid "Title"
23 44 msgstr "Заголовок"
24 45
46 #: templates/posting_general.html:53 templates/thread.html:46
25 47 msgid "Text"
26 48 msgstr "Текст"
27 49
50 #: templates/posting_general.html:57 templates/thread.html:50
28 51 msgid "Image"
29 52 msgstr "Картинка"
30 53
54 #: templates/posting_general.html:64 templates/thread.html:53
31 55 msgid "Post"
32 56 msgstr "Отправить"
33 57
34 msgid "Tags"
35 msgstr "Теги"
36
37 msgid "View"
38 msgstr "Просмотр"
39
40 msgid "Create new thread"
41 msgstr "Создать новый тред"
42
58 #: templates/thread.html:39
43 59 msgid "Reply to the thread"
44 msgstr "Ответить в тред" No newline at end of file
60 msgstr "Ответить в тред"
@@ -18,10 +18,14 b''
18 18 <span class="title">{{ thread.title }}</span>
19 19 <span class="post_id">(#{{ thread.id }})</span>
20 20 [{{ thread.pub_time }}]
21 <a class="link" href="/thread/{{ thread.id }}/">
22 [{% trans "View" %}]</a><br />
21 [<a class="link" href="/thread/{{ thread.id }}/">{% trans "View" %}</a>]<br />
23 22 {{ thread.text|truncatechars:300 }}<br />
24 {% if thread.tags %}
23 <div class="metadata">
24 ({{ thread.get_reply_count }} {% trans 'replies' %},
25 {{ thread.get_images_count }} {% trans 'images' %},
26 {{ thread.get_gets_count }} {% trans 'gets' %})
27 <br />
28 {% if thread.tags.all %}
25 29 <span class="tags">{% trans 'Tags' %}:
26 30 {% for tag in thread.tags.all %}
27 31 <a class="tag" href="/tag/{{ tag.name }}">
@@ -31,6 +35,7 b''
31 35 {% endif %}
32 36 </div>
33 37 </div>
38 </div>
34 39 {% endfor %}
35 40 {% else %}
36 41 No threads found.
@@ -6,6 +6,7 b''
6 6
7 7 {% if posts %}
8 8 {% for post in posts %}
9 <a name="{{ post.id }}"></a>
9 10 <div class="post">
10 11 {% if post.image %}
11 12 <div class="block">
@@ -16,17 +17,20 b''
16 17 {% endif %}
17 18 <div class="block">
18 19 <span class="title">{{ post.title }}</span>
19 <span class="post_id">(#{{ post.id }})</span>
20 <a class="post_id" href="#{{ post.id }}">
21 (#{{ post.id }})</a>
20 22 [{{ post.pub_time }}]<br />
21 23 {{ post.text }}<br />
22 {% ifnotequal post.tags.all|length 0 %}
24 {% if post.tags.all %}
25 <div class="metadata">
23 26 <span class="tags">{% trans 'Tags' %}:
24 27 {% for tag in post.tags.all %}
25 28 <a class="tag" href="/tag/{{ tag.name }}">
26 29 {{ tag.name }}</a>
27 30 {% endfor %}
28 31 </span>
29 {% endifnotequal %}
32 </div>
33 {% endif %}
30 34 </div>
31 35 </div>
32 36 {% endfor %}
General Comments 0
You need to be logged in to leave comments. Login now