# HG changeset patch # User neko259 # Date 2015-08-12 15:37:28 # Node ID 819f972ff3323d07280fa16fc50ecfbffa0f5cee # Parent 59984fb195408c78400dffec82973a7fa04c45dd Show related tags in the tag page diff --git a/boards/locale/ru/LC_MESSAGES/django.mo b/boards/locale/ru/LC_MESSAGES/django.mo index c430bbf78d49e077b880ab8529e2e4f4b09fd798..35e8b7e1536721479164a4f6f1881106e815743e GIT binary patch literal 7750 zc$|$_Yj9Q772dU4nr9)91jN{lEegeZNkA&S5G6o>)P%%5w4gRU$vq@TZqB`)b8j>q zM?pkzf`0* z>z$nQo&8#SJ-)T}&ZV*|pH=up@mzyv>nD|Z9C-Jq6#ou=TB$36hk^K0kKt7Y90Fbi zd=Xd#{DHwy;3D8pfh6MRzyjc}fQ7){nejgWmjK@fmIFUB`z$MveO45Ryz79gf#Cuf zZ!eJb`+&tjt3dQ{3uK=pUK;oi@H4>Ez*WGX09OFhM(!Vh*8=}(+7(c)g!TiL0;_>n z18*%9x%&%6UbIl`NEV7-4+C!iey>pM{iT`zrjd6Ecm>&6DEj}oQ1<)4%%?^Ou&7AJ zHx-HeNRilCUnFvxip0*lOxr3Fed4D5u$ljanfI(2f8NOZv5|kSNcNp75w&d zFamt5NO-WgSmcF@CElBgW!)YiD59E+#ZPU;BDV{;71(3iF9ELy{;*i=4T?pt-vgHe z-vQnU{7`Ii% z{DD%Dcf^bz2QDKXmx`S)nfb2(tAJyrBL6pL{<{YMWaNAR9RGw;ADZ^r#Y(Lt|1K6@ z{2F*2@L!8%pOs4_9@R^Px7(J8ADV!l1s+%;{Co^p0eoSJtRG(@{&*V*QR<2^*=K2) z%wG@O18gXhI6qY;aXD2c{C%ZNTIoy+Zu^#tMml!PUaQwZM(Q4Z!<}7r;u2+tnifAHdsa{z|c@19+11 zZ>7ln`%01b(Ms{pwJ>r3cr)-`;^{Rq@0u#{!wpqp|K=*`Z#M1yRbtnDRkH8X244n# z5jX+75%?F=Uv;gluQs>^i1bijP?ERxO6({Rk29+3@S!*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ImyD7Sjw|vp6+GYrq zP6ne`be`uNhKxhNLs&Hespt#FRPa>#FqY&*)7`^#=F1sDVPNg6ANJ<%=)pb!0t2Lg$Xmj4 z%$yNlFSs#|`Dpzvune~NV!S8UCEyOAG1k)p3V7B>^G%Lc*E`r zCL~#c85Mlj{Gb zY{~@>j0#047pNLiWx(puj1^<_iI8zlP>r6%s)>1SV@3030=y*aaMgM?=VOo%^JsID1wySlY91oypnGIXlTl$oX_4_ixAi z4C8VrXT%9wc#)Oovw=@fgpQ~;iSZ+RKFlsoXQ*UQq^W}(qk?Z|YAaJ3N)y~`rmhtql zY~E(i42tUlF3NKtIf-_drjJ)S$P;riij2I#$sjD^WvFN5D+t%=C(N>}W4SRVq5t^* ze@QaHRdfIQTA(Vc;QM?BnqfO9xP+yLDEM^WdM#r+)&2##=6LeFD4x9yq)()eU(T1$ zm^wH@HTo$Y$<)mG#e!V+B%KAI#B+Qq&v1;#x%isXVVKXC8=#x0IQNWj-wY2k&4Ve; zRe6E?Hy^lEwa-ZqNRp;y!}IpMx^PAZC0q!y6GG?zQ= ZG=ezAT;`LJCeJw)6^GdzEV=)={tKM-i$nkb diff --git a/boards/locale/ru/LC_MESSAGES/django.po b/boards/locale/ru/LC_MESSAGES/django.po --- a/boards/locale/ru/LC_MESSAGES/django.po +++ b/boards/locale/ru/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-08-10 10:22+0300\n" +"POT-Creation-Date: 2015-08-12 18:32+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -111,7 +111,7 @@ msgstr "Текст или картинка должны быть введены." msgid "Image must be less than %s bytes" msgstr "Изображение должно быть менее %s байт" -#: forms.py:338 templates/boards/all_threads.html:141 +#: forms.py:338 templates/boards/all_threads.html:154 #: templates/boards/rss/post.html:10 templates/boards/tags.html:6 msgid "Tags" msgstr "Метки" @@ -156,62 +156,68 @@ msgstr "Этой страницы не существует" msgid "Related message" msgstr "Связанное сообщение" -#: templates/boards/all_threads.html:68 +#: templates/boards/all_threads.html:71 msgid "Edit tag" msgstr "Изменить метку" -#: templates/boards/all_threads.html:76 +#: templates/boards/all_threads.html:79 #, python-format -#| msgid "This tag has %(thread_count)s threads and %(post_count)s posts." msgid "" "This tag has %(active_thread_count)s/%(thread_count)s threads and " "%(post_count)s posts." -msgstr "С этой меткой есть %(active_thread_count)s/%(thread_count)s тем и %(post_count)s сообщений." +msgstr "" +"С этой меткой есть %(active_thread_count)s/%(thread_count)s тем и " +"%(post_count)s сообщений." -#: templates/boards/all_threads.html:83 templates/boards/feed.html:30 +#: templates/boards/all_threads.html:81 +#| msgid "Related message" +msgid "Related tags:" +msgstr "Похожие метки:" + +#: templates/boards/all_threads.html:96 templates/boards/feed.html:30 #: templates/boards/notifications.html:17 templates/search/search.html:26 msgid "Previous page" msgstr "Предыдущая страница" -#: templates/boards/all_threads.html:97 +#: templates/boards/all_threads.html:110 #, python-format msgid "Skipped %(count)s replies. Open thread to see all replies." msgstr "Пропущено %(count)s ответов. Откройте тред, чтобы увидеть все ответы." -#: templates/boards/all_threads.html:115 templates/boards/feed.html:40 +#: templates/boards/all_threads.html:128 templates/boards/feed.html:40 #: templates/boards/notifications.html:27 templates/search/search.html:37 msgid "Next page" msgstr "Следующая страница" -#: templates/boards/all_threads.html:120 +#: templates/boards/all_threads.html:133 msgid "No threads exist. Create the first one!" msgstr "Нет тем. Создайте первую!" -#: templates/boards/all_threads.html:126 +#: templates/boards/all_threads.html:139 msgid "Create new thread" msgstr "Создать новую тему" -#: templates/boards/all_threads.html:131 templates/boards/preview.html:16 +#: templates/boards/all_threads.html:144 templates/boards/preview.html:16 #: templates/boards/thread_normal.html:38 msgid "Post" msgstr "Отправить" -#: templates/boards/all_threads.html:136 +#: templates/boards/all_threads.html:149 msgid "Tags must be delimited by spaces. Text or image is required." msgstr "" "Метки должны быть разделены пробелами. Текст или изображение обязательны." -#: templates/boards/all_threads.html:138 templates/boards/preview.html:6 +#: templates/boards/all_threads.html:151 templates/boards/preview.html:6 #: templates/boards/staticpages/help.html:21 #: templates/boards/thread_normal.html:42 msgid "Preview" msgstr "Предпросмотр" -#: templates/boards/all_threads.html:140 templates/boards/thread_normal.html:45 +#: templates/boards/all_threads.html:153 templates/boards/thread_normal.html:45 msgid "Text syntax" msgstr "Синтаксис текста" -#: templates/boards/all_threads.html:154 templates/boards/feed.html:53 +#: templates/boards/all_threads.html:167 templates/boards/feed.html:53 msgid "Pages:" msgstr "Страницы: " @@ -391,15 +397,15 @@ msgstr "Цитата" msgid "You can try pasting the text and previewing the result here:" msgstr "Вы можете попробовать вставить текст и проверить результат здесь:" -#: templates/boards/tags.html:14 +#: templates/boards/tags.html:17 msgid "Sections:" msgstr "Разделы:" -#: templates/boards/tags.html:26 +#: templates/boards/tags.html:30 msgid "Other tags:" msgstr "Другие метки:" -#: templates/boards/tags.html:38 +#: templates/boards/tags.html:43 msgid "All tags..." msgstr "Все метки..." diff --git a/boards/models/tag.py b/boards/models/tag.py --- a/boards/models/tag.py +++ b/boards/models/tag.py @@ -17,7 +17,7 @@ class TagManager(models.Manager): Gets tags that have non-archived threads. """ - return self.annotate(num_threads=Count('thread')).filter(num_threads__gt=0)\ + return self.annotate(num_threads=Count('thread_tags')).filter(num_threads__gt=0)\ .order_by('-required', 'name') def get_tag_url_list(self, tags: list) -> str: @@ -67,7 +67,7 @@ class Tag(models.Model, Viewable): return reverse('tag', kwargs={'tag_name': self.name}) def get_threads(self): - return self.thread_set.order_by('-bump_time') + return self.thread_tags.order_by('-bump_time') def is_required(self): return self.required @@ -100,3 +100,7 @@ class Tag(models.Model, Viewable): def get_first_letter(self): return self.name and self.name[0] or '' + + def get_related_tags(self): + return Tag.objects.filter(thread_tags__in=self.get_threads()).exclude( + id=self.id).distinct() diff --git a/boards/models/thread.py b/boards/models/thread.py --- a/boards/models/thread.py +++ b/boards/models/thread.py @@ -65,7 +65,7 @@ class Thread(models.Model): class Meta: app_label = 'boards' - tags = models.ManyToManyField('Tag') + tags = models.ManyToManyField('Tag', related_name='thread_tags') bump_time = models.DateTimeField(db_index=True) last_edit_time = models.DateTimeField() archived = models.BooleanField(default=False) diff --git a/boards/templates/boards/all_threads.html b/boards/templates/boards/all_threads.html --- a/boards/templates/boards/all_threads.html +++ b/boards/templates/boards/all_threads.html @@ -77,6 +77,15 @@ {% endautoescape %} {% endif %}

{% blocktrans with active_thread_count=tag.get_active_thread_count thread_count=tag.get_thread_count post_count=tag.get_post_count %}This tag has {{ active_thread_count}}/{{ thread_count }} threads and {{ post_count }} posts.{% endblocktrans %}

+ {% if related_tags %} +

{% trans 'Related tags:' %} + {% for rel_tag in related_tags %} + {% autoescape off %} + {{ rel_tag.get_view }}{% if not forloop.last %}, {% endif %} + {% endautoescape %} + {% endfor %} +

+ {% endif %} {% endif %} diff --git a/boards/views/tag_threads.py b/boards/views/tag_threads.py --- a/boards/views/tag_threads.py +++ b/boards/views/tag_threads.py @@ -13,6 +13,8 @@ PARAM_TAG = 'tag' PARAM_IS_FAVORITE = 'is_favorite' PARAM_IS_HIDDEN = 'is_hidden' PARAM_RANDOM_IMAGE_POST = 'random_image_post' +PARAM_RELATED_TAGS = 'related_tags' + __author__ = 'neko259' @@ -49,6 +51,7 @@ class TagView(AllThreadsView, Dispatcher params[PARAM_IS_HIDDEN] = hidden_tag_names is not None and tag.name in hidden_tag_names params[PARAM_RANDOM_IMAGE_POST] = tag.get_random_image_post() + params[PARAM_RELATED_TAGS] = tag.get_related_tags().all() return params