X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/c6d5dd71ad0d9bae811cc9002248d9399c7fdff7..d69fc5f16ed739c02685e7d695abf6de59c2bf5e:/apps/chunks/templatetags/chunks.py diff --git a/apps/chunks/templatetags/chunks.py b/apps/chunks/templatetags/chunks.py deleted file mode 100644 index cc25df728..000000000 --- a/apps/chunks/templatetags/chunks.py +++ /dev/null @@ -1,38 +0,0 @@ -from django import template -from django.db import models -from django.core.cache import cache - - -register = template.Library() - -Chunk = models.get_model('chunks', 'chunk') -Attachment = models.get_model('chunks', 'attachment') - - -@register.simple_tag -def chunk(key, cache_time=0): - try: - cache_key = Chunk.cache_key(key) - c = cache.get(cache_key) - if c is None: - c = Chunk.objects.get(key=key) - cache.set(cache_key, c, int(cache_time)) - content = c.content - except Chunk.DoesNotExist: - n = Chunk(key=key) - n.save() - return '' - return content - - -@register.simple_tag -def attachment(key, cache_time=0): - try: - cache_key = 'attachment_' + key - c = cache.get(cache_key) - if c is None: - c = Attachment.objects.get(key=key) - cache.set(cache_key, c, int(cache_time)) - return c.attachment.url - except Attachment.DoesNotExist: - return ''