add: alltags page and tag styles
This commit is contained in:
@@ -30,6 +30,7 @@ urlpatterns = [
|
|||||||
re_path(r'^p(?P<ppage>\d*)$', views.index),
|
re_path(r'^p(?P<ppage>\d*)$', views.index),
|
||||||
re_path(r'^tag_(?P<slug_tags>[^/]*)$', views.index),
|
re_path(r'^tag_(?P<slug_tags>[^/]*)$', views.index),
|
||||||
re_path(r'^tag_(?P<slug_tags>[^/]*)[^/]*/p(?P<ppage>\d*)$', views.index),
|
re_path(r'^tag_(?P<slug_tags>[^/]*)[^/]*/p(?P<ppage>\d*)$', views.index),
|
||||||
|
re_path(r'^alltags$', views.alltags, name='web_alltags'),
|
||||||
# Статья
|
# Статья
|
||||||
re_path(r'^item/(?P<content_id>\d*)-\S*$', views.show_item),
|
re_path(r'^item/(?P<content_id>\d*)-\S*$', views.show_item),
|
||||||
# После чистки кросс-ссылок в контенте legacy Joomla-редиректы временно
|
# После чистки кросс-ссылок в контенте legacy Joomla-редиректы временно
|
||||||
|
|||||||
32
cadpoint/templates/alltags.jinja2
Normal file
32
cadpoint/templates/alltags.jinja2
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{% extends "base.jinja2" %}{% load slug_ru %}
|
||||||
|
|
||||||
|
{% block Title %}Все теги{% endblock %}
|
||||||
|
{% block canonical %}https://cadpoint.ru/alltags{% endblock %}
|
||||||
|
{% block Description %}Все теги сайта CADpoint{% endblock %}
|
||||||
|
{% block Keywords %}cadpoint, теги, alltags, новости{% endblock %}
|
||||||
|
|
||||||
|
{% block CONTENT %}
|
||||||
|
<div class="container bread-crumb">
|
||||||
|
<div class="row">
|
||||||
|
<nav class="col-12" aria-label="breadcrumb">
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<li class="breadcrumb-item nw s"><a href="/"><i class="bi bi-house-door" title="Главная"></i> Главная</a></li>
|
||||||
|
<li class="breadcrumb-item active nw s" aria-current="page">Все теги</li>
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container lenta">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<h1>Все теги сайта</h1>
|
||||||
|
<p class="tags text-center">{% if TAGS_IN_PAGE %}{% for I in TAGS_IN_PAGE %}
|
||||||
|
<a href="/tag_{{ I.slug|lower }}" class="tag-active">
|
||||||
|
{{ I.name }} <span class="tag-note"><b class="_tag">{{ I.NumTotal }}</b></span>
|
||||||
|
</a>{% endfor %}
|
||||||
|
{% else %}<span class="tag-not-active">Тегов пока нет</span>{% endif %}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -143,6 +143,44 @@ class TagAutocompleteTests(TestCase):
|
|||||||
self.assertEqual(payload['pagination']['more'], False)
|
self.assertEqual(payload['pagination']['more'], False)
|
||||||
|
|
||||||
|
|
||||||
|
class AllTagsPageTests(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
user_model = get_user_model()
|
||||||
|
self.user = user_model.objects.create_superuser(
|
||||||
|
username='admin',
|
||||||
|
email='admin@example.com',
|
||||||
|
password='password',
|
||||||
|
)
|
||||||
|
self.client.force_login(self.user)
|
||||||
|
|
||||||
|
item1 = TbContent.objects.create(
|
||||||
|
szContentHead='Тест 1',
|
||||||
|
szContentIntro='Анонс 1',
|
||||||
|
szContentBody='Тело 1',
|
||||||
|
szContentSlug='test-1',
|
||||||
|
bContentPublish=True,
|
||||||
|
)
|
||||||
|
item2 = TbContent.objects.create(
|
||||||
|
szContentHead='Тест 2',
|
||||||
|
szContentIntro='Анонс 2',
|
||||||
|
szContentBody='Тело 2',
|
||||||
|
szContentSlug='test-2',
|
||||||
|
bContentPublish=True,
|
||||||
|
)
|
||||||
|
item1.tags.add('alpha', 'beta')
|
||||||
|
item2.tags.add('alpha')
|
||||||
|
|
||||||
|
def test_alltags_page_lists_all_tags_with_counts(self):
|
||||||
|
response = self.client.get(reverse('web_alltags'))
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertContains(response, 'Все теги сайта')
|
||||||
|
self.assertContains(response, '/tag_alpha')
|
||||||
|
self.assertContains(response, '/tag_beta')
|
||||||
|
self.assertContains(response, '<b class="_tag">2</b>')
|
||||||
|
self.assertContains(response, '<b class="_tag">1</b>')
|
||||||
|
|
||||||
|
|
||||||
class TypographTests(TestCase):
|
class TypographTests(TestCase):
|
||||||
def test_save_generates_slug_from_clean_text(self):
|
def test_save_generates_slug_from_clean_text(self):
|
||||||
item = TbContent(szContentHead='<b>Привет мир</b>')
|
item = TbContent(szContentHead='<b>Привет мир</b>')
|
||||||
|
|||||||
@@ -60,6 +60,24 @@ def tag_autocomplete(request):
|
|||||||
return JsonResponse({"results": results, "pagination": {"more": more}})
|
return JsonResponse({"results": results, "pagination": {"more": more}})
|
||||||
|
|
||||||
|
|
||||||
|
@require_GET
|
||||||
|
def alltags(request):
|
||||||
|
"""Показывает все теги сайта и число их вхождений во всех публикациях."""
|
||||||
|
template = "alltags.jinja2"
|
||||||
|
to_template: dict[str, object] = {"COOKIES": check_cookies(request)}
|
||||||
|
|
||||||
|
q_tags = (
|
||||||
|
Tag.objects.annotate(
|
||||||
|
NumTotal=Count("taggit_taggeditem_items", distinct=True),
|
||||||
|
)
|
||||||
|
.filter(NumTotal__gt=0)
|
||||||
|
.order_by("-NumTotal", "name")
|
||||||
|
)
|
||||||
|
|
||||||
|
to_template["TAGS_IN_PAGE"] = q_tags
|
||||||
|
return render(request, template, to_template)
|
||||||
|
|
||||||
|
|
||||||
def index(request,
|
def index(request,
|
||||||
slug_tags: str = "",
|
slug_tags: str = "",
|
||||||
ppage: int = 0):
|
ppage: int = 0):
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ div.news > nav.row { margin: 0; }
|
|||||||
}
|
}
|
||||||
/* левые треугольные хвостики не активного тега (с ненулевой представленностью на странице) серые */
|
/* левые треугольные хвостики не активного тега (с ненулевой представленностью на странице) серые */
|
||||||
.tags > a.tag-not-active:before {
|
.tags > a.tag-not-active:before {
|
||||||
background: -moz-linear-gradient(45deg, #ccc 0%, #888 100%);7
|
background: -moz-linear-gradient(45deg, #ccc 0%, #888 100%);
|
||||||
background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,#ccc), color-stop(100%,#888));
|
background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,#ccc), color-stop(100%,#888));
|
||||||
background: -webkit-linear-gradient(-45deg, #ccc 0%,#888 100%);
|
background: -webkit-linear-gradient(-45deg, #ccc 0%,#888 100%);
|
||||||
background: -o-linear-gradient(45deg, #ccc 0%,#888 100%);
|
background: -o-linear-gradient(45deg, #ccc 0%,#888 100%);
|
||||||
@@ -357,6 +357,10 @@ div.news > nav.row { margin: 0; }
|
|||||||
.tags > a.tag-not-active:hover .tag-note { color: #008DD2; }
|
.tags > a.tag-not-active:hover .tag-note { color: #008DD2; }
|
||||||
.tags > a:not(:hover), .tags > a:not(:hover) .tag-note { transition:1s; }
|
.tags > a:not(:hover), .tags > a:not(:hover) .tag-note { transition:1s; }
|
||||||
|
|
||||||
|
/* Для страницы всех тегов */
|
||||||
|
a.tag-active > .tag-note > ._tag { color: #fee; transition:0.5s;}
|
||||||
|
a.tag-active:hover > .tag-note > ._tag { color: #008DD2; transition:0.5s;}
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
** ОФОРМЛЕНИЕ ТЕГОВ *********
|
** ОФОРМЛЕНИЕ ТЕГОВ *********
|
||||||
****************************/
|
****************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user