X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/6d42bc478e3d1bd90eb294464748c21e4de0fc63..f16fb0040e6beb395ffea1ac252658ab0b8ac3f7:/src/chunks/templatetags/chunks.py diff --git a/src/chunks/templatetags/chunks.py b/src/chunks/templatetags/chunks.py index e86288ef7..b8e9f4f6d 100644 --- a/src/chunks/templatetags/chunks.py +++ b/src/chunks/templatetags/chunks.py @@ -11,8 +11,8 @@ from ..models import Chunk, Attachment register = template.Library() -@register.simple_tag -def chunk(key, cache_time=0): +@register.simple_tag(takes_context=True) +def chunk(context, key, cache_time=0): try: cache_key = 'chunk:%s:%s' % (key, get_language()) c = cache.get(cache_key) @@ -23,7 +23,11 @@ def chunk(key, cache_time=0): except Chunk.DoesNotExist: n = Chunk(key=key) n.save() - return '' + content = '' + + if 'request' in context and context['request'].user.is_staff: + content = f'' + content + return mark_safe(content)