show item count in sidebar/tags
This commit is contained in:
parent
9a58ddb785
commit
dcc137c389
4 changed files with 7 additions and 13 deletions
|
@ -11,7 +11,8 @@
|
|||
border-radius: calc(var(--pico-spacing)/4);
|
||||
line-height: 1.2em;
|
||||
font-size: 80%;
|
||||
margin: 3px !important;
|
||||
margin: 0.5em !important;
|
||||
margin-right: 0 !important;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
display: inline-block;
|
||||
|
|
|
@ -187,7 +187,8 @@
|
|||
<div class="tag-list">
|
||||
{% for t in top_tags %}
|
||||
<span>
|
||||
<a href="{% url 'journal:user_tag_member_list' identity.user.handler t %}">{{ t }}</a>
|
||||
<a href="{% url 'journal:user_tag_member_list' identity.user.handler t.title %}">{{ t.title }}</a>
|
||||
<small>({{ t.total }})</small>
|
||||
</span>
|
||||
{% empty %}
|
||||
<div class="empty">暂无可见标签</div>
|
||||
|
|
|
@ -80,15 +80,10 @@ class TagManager:
|
|||
|
||||
@staticmethod
|
||||
def all_tags_by_owner(owner, public_only=False):
|
||||
tags = (
|
||||
owner.tag_set.all()
|
||||
.values("title")
|
||||
.annotate(frequency=Count("members__id"))
|
||||
.order_by("-frequency")
|
||||
)
|
||||
tags = owner.tag_set.all().annotate(total=Count("members")).order_by("-total")
|
||||
if public_only:
|
||||
tags = tags.filter(visibility=0)
|
||||
return list(map(lambda t: t["title"], tags))
|
||||
return tags
|
||||
|
||||
@staticmethod
|
||||
def tag_item(
|
||||
|
|
|
@ -20,10 +20,7 @@ PAGE_SIZE = 10
|
|||
@target_identity_required
|
||||
def user_tag_list(request, user_name):
|
||||
target = request.target_identity
|
||||
tags = Tag.objects.filter(owner=target)
|
||||
if target.user != request.user:
|
||||
tags = tags.filter(visibility=0)
|
||||
tags = tags.values("title").annotate(total=Count("members")).order_by("-total")
|
||||
tags = TagManager.all_tags_by_owner(target, target.user != request.user)
|
||||
return render(
|
||||
request,
|
||||
"user_tag_list.html",
|
||||
|
|
Loading…
Add table
Reference in a new issue