X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/d0072de89eb395f99aedcdf7804e48b547cbbeca..69191eddb9e4221d964a7e5b044ff7c5dfe38315:/apps/social/templatetags/social_tags.py diff --git a/apps/social/templatetags/social_tags.py b/apps/social/templatetags/social_tags.py index deac93df0..e78f20f0a 100755 --- a/apps/social/templatetags/social_tags.py +++ b/apps/social/templatetags/social_tags.py @@ -28,4 +28,14 @@ def cite_promo(ctx=None, fallback=False): 'cite': cites.order_by('?')[0] if cites.exists() else None, 'fallback': fallback, 'ctx': ctx, - } \ No newline at end of file + } + + +@register.inclusion_tag('social/shelf_tags.html', takes_context=True) +def shelf_tags(context, book): + user = context['request'].user + if not user.is_authenticated(): + tags = [] + else: + tags = book.tags.filter(category='set', user=user).exclude(name='') + return {'tags': tags}