X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/c0a7799619e217e2eac724b1a688ad37f0182253..356ce56229b7439ae6f35f8f80e480bdfa8bff56:/src/social/models.py?ds=inline
diff --git a/src/social/models.py b/src/social/models.py
index c9334d833..29029ee6b 100644
--- a/src/social/models.py
+++ b/src/social/models.py
@@ -6,9 +6,9 @@ from django.db import models
from django.conf import settings
from django.core.exceptions import ValidationError
from django.urls import reverse
-from django.utils.translation import ugettext_lazy as _, string_concat
-from ssify import flush_ssi_includes
+from django.utils.translation import ugettext_lazy as _
from catalogue.models import Book
+from wolnelektury.utils import cached_render, clear_cached_renders
class BannerGroup(models.Model):
@@ -53,7 +53,9 @@ class Cite(models.Model):
sticky = models.BooleanField(_('sticky'), default=False, db_index=True,
help_text=_('Sticky cites will take precedense.'))
- banner = models.BooleanField(_('banner'), default=False, help_text=string_concat(_('Adjust size to image, ignore the text'), '
(PrzestarzaÅe; użyj funkcji "Obraz" w sekcji "Media box")'))
+ banner = models.BooleanField(_('banner'), default=False, help_text=
+ 'Dostosuj wielkoÅÄ do obrazu tÅa, zignoruj tekst.'
+ '
(PrzestarzaÅe; użyj funkcji "Obraz" w sekcji "Media box")')
background_plain = models.BooleanField(_('plain background'), default=False)
background_color = models.CharField(_('background color'), max_length=32, blank=True)
@@ -62,7 +64,8 @@ class Cite(models.Model):
help_text=_('Best image is exactly 975px wide and weights under 100kB.'))
image_shift = models.IntegerField(
_('shift'), null=True, blank=True,
- help_text=string_concat(_('Vertical shift, in percents. 0 means top, 100 is bottom. Default is 50%.'), '
(PrzestarzaÅe; użyj obrazka o wÅaÅciwych proporcjach;)'))
+ help_text='PrzesuniÄcie w pionie, w procentach. 0 to wyrównanie do górnej krawÄdzi, 100 do dolnej. DomyÅlne jest 50%.'
+ '
(PrzestarzaÅe; użyj obrazka o wÅaÅciwych proporcjach;)')
image_title = models.CharField(_('title'), max_length=255, null=True, blank=True)
image_author = models.CharField(_('author'), max_length=255, blank=True, null=True)
image_link = models.URLField(_('link'), blank=True, null=True)
@@ -116,18 +119,18 @@ class Cite(models.Model):
def save(self, *args, **kwargs):
ret = super(Cite, self).save(*args, **kwargs)
- self.flush_includes()
+ self.clear_cache()
return ret
- def flush_includes(self):
- flush_ssi_includes([
- template % (self.pk, lang)
- for template in [
- '/ludzie/cite/%s.%s.html',
- '/ludzie/cite_main/%s.%s.html',
- ]
- for lang in [lc for (lc, _ln) in settings.LANGUAGES]] +
- ['/ludzie/cite_info/%s.html' % self.pk])
+ @cached_render('social/cite_promo.html')
+ def main_box(self):
+ return {
+ 'cite': self,
+ 'main': True,
+ }
+
+ def clear_cache(self):
+ clear_cached_renders(self.main_box)
class Carousel(models.Model):