X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/938fc832934e508085dad3645c01060a4dc9f0c9..1ca6872afcca0bb6fb4c0c11fdad3b760a2362a1:/apps/picture/models.py?ds=sidebyside diff --git a/apps/picture/models.py b/apps/picture/models.py index 0217d8bad..dc92c43d6 100644 --- a/apps/picture/models.py +++ b/apps/picture/models.py @@ -6,10 +6,10 @@ from django.conf import settings from django.core.files.storage import FileSystemStorage from django.utils.datastructures import SortedDict from django.template.loader import render_to_string -from django.core.cache import cache +from django.core.cache import get_cache from catalogue.utils import split_tags from django.utils.safestring import mark_safe -from slughifi import slughifi +from fnpdjango.utils.text.slughifi import slughifi from django.utils.translation import ugettext_lazy as _ from newtagging import managers @@ -148,7 +148,7 @@ class Picture(models.Model): for tag in catalogue.models.Tag.objects.filter(category='author'): pics_by_author[tag] = [] - for pic in pics: + for pic in pics.iterator(): authors = list(pic.tags.filter(category='author')) if authors: for author in authors: @@ -172,24 +172,24 @@ class Picture(models.Model): return cache_key = "Picture.short_html/%d" % (self.id) - cache.delete(cache_key) + get_cache('permanent').delete(cache_key) def short_html(self): if self.id: cache_key = "Picture.short_html/%d" % (self.id) - short_html = cache.get(cache_key) + short_html = get_cache('permanent').get(cache_key) else: short_html = None if short_html is not None: return mark_safe(short_html) else: - tags = self.tags.filter(category__in=('author', 'kind', 'epoch')) + tags = self.tags.filter(category__in=('author', 'kind', 'epoch', 'genre')) tags = split_tags(tags) short_html = unicode(render_to_string('picture/picture_short.html', {'picture': self, 'tags': tags})) if self.id: - cache.set(cache_key, short_html, catalogue.models.CACHE_FOREVER) + get_cache('permanent').set(cache_key, short_html) return mark_safe(short_html)