-@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}
+@ssi_variable(register, patch_response=[ssi_vary_on_cookie])
+def book_shelf_tags(request, book_id):
+ if not request.user.is_authenticated():
+ return None
+ book = Book.objects.get(pk=book_id)
+ lks = likes(request.user, book, request)
+ def get_value():
+ if not lks:
+ return ''
+ tags = book.tags.filter(category='set', user=request.user).exclude(name='')
+ if not tags:
+ return ''
+ ctx = {'tags': tags}
+ return template.loader.render_to_string('social/shelf_tags.html', ctx)
+ return lazy(get_value, unicode)()