from django.contrib.contenttypes.fields import GenericRelation
from django.urls import reverse
from django.db import models
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
from newtagging import managers
from catalogue.models import Tag
-from ssify import flush_ssi_includes
+from wolnelektury.utils import cached_render, clear_cached_renders
class Fragment(models.Model):
tags = managers.TagDescriptor(Tag)
tag_relations = GenericRelation(Tag.intermediary_table_model)
- short_html_url_name = 'catalogue_fragment_short'
-
class Meta:
ordering = ('book', 'anchor',)
verbose_name = _('fragment')
@property
def themes(self):
return self.tags.filter(category='theme')
-
- def flush_includes(self, languages=True):
- if not languages:
- return
- if languages is True:
- languages = [lc for (lc, _ln) in settings.LANGUAGES]
- flush_ssi_includes([
- template % (self.pk, lang)
- for template in [
- '/katalog/f/%d/short.%s.html',
- '/api/include/fragment/%d.%s.json',
- '/api/include/fragment/%d.%s.xml',
- ]
- for lang in languages
- ])