From 224932a29cbc56892c4ec6eb2d0d4e9d3fb09be9 Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Sun, 8 Nov 2015 20:37:42 -0500 Subject: [PATCH] Get private snipts count for Intercom. --- snipts/templatetags/snipt_tags.py | 13 +++++++++++++ templates/base.html | 1 + 2 files changed, 14 insertions(+) diff --git a/snipts/templatetags/snipt_tags.py b/snipts/templatetags/snipt_tags.py index fab326a..f441a6c 100644 --- a/snipts/templatetags/snipt_tags.py +++ b/snipts/templatetags/snipt_tags.py @@ -29,6 +29,19 @@ def snipt_is_favorited_by_user(context, asvar): return '' +@tag(register, []) +def private_snipts_count_for_user(context): + + user = context['request'].user + + if user.is_authenticated(): + snipts = Snipt.objects.filter(user=user, public=False).values('id').count() + else: + snipts = 0 + + return snipts + + @tag(register, []) def snipts_count_for_user(context): diff --git a/templates/base.html b/templates/base.html index f34e9a0..b1a806d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -454,6 +454,7 @@ created_at: {{ request.user.date_joined|date:"U" }}, custom_data: { 'snipts count': {% snipts_count_for_user %}, + 'snipts count private': {% private_snipts_count_for_user %}, 'profile link': 'https://snipt.net/{{ request.user.username }}/', 'is pro': window.user_has_pro, 'blog domain': '{{ request.user.profile.blog_domain }}',