def save(self, *args, **kwargs): flush_cache = flush_all_includes = False if self.pk and self.category != 'set': # Flush the whole views cache. # Seem a little harsh, but changed tag names, descriptions # and links come up at any number of places. flush_cache = True # Find in which languages we need to flush related includes. old_self = type(self).objects.get(pk=self.pk) # Category shouldn't normally be changed, but just in case. if self.category != old_self.category: flush_all_includes = True languages_changed = self.languages_changed(old_self) ret = super(Tag, self).save(*args, **kwargs) if flush_cache: caches[settings.CACHE_MIDDLEWARE_ALIAS].clear() if flush_all_includes: flush_ssi_includes() else: self.flush_includes() self.after_change.send(sender=type(self), instance=self, languages=languages_changed) return ret
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([ '/katalog/%s.json' % lang for lang in languages])
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])
def receive_tags_updated(sender, instance, affected_tags, **kwargs): categories = set(tag.category for tag in affected_tags if tag.category not in ('set', 'book')) if not categories: return caches[settings.CACHE_MIDDLEWARE_ALIAS].clear() instance.flush_includes() flush_ssi_includes([ '/katalog/%s.json' % lang for lang in [lc for (lc, _ln) in settings.LANGUAGES]])
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 ])
def book_delete(sender, instance, **kwargs): caches[settings.CACHE_MIDDLEWARE_ALIAS].clear() flush_ssi_includes([ '/katalog/%s.json' % lang for lang in [lc for (lc, _ln) in settings.LANGUAGES]]) if not settings.NO_SEARCH_INDEX: # remove the book from search index, when it is deleted. from search.index import Index idx = Index() idx.remove_book(instance) idx.index_tags()
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/pa/%d/short.%s.html', ] for lang in languages ])
def tag_after_change(sender, instance, languages, **kwargs): caches[settings.CACHE_MIDDLEWARE_ALIAS].clear() flush_ssi_includes([ '/katalog/%s.json' % lang for lang in [lc for (lc, _ln) in settings.LANGUAGES]]) for model in Book, Picture: for model_instance in model.tagged.with_all([instance]).only('pk'): model_instance.flush_includes() if instance.category == 'author': for model in Fragment, PictureArea: for model_instance in model.tagged.with_all([instance]).only('pk'): model_instance.flush_includes()
def flush_includes(self): flush_ssi_includes([ template % (self.pk, lang) for template in [ '/wesprzyj/o/%d/top-bar.%s.html', '/wesprzyj/o/%d/detail-bar.%s.html', '/wesprzyj/o/%d/list-bar.%s.html', '/wesprzyj/o/%d/status.%s.html', '/wesprzyj/o/%d/status-more.%s.html', ] + [ '/wesprzyj/o/%%d/fundings/%d.%%s.html' % page for page in range(1, len(self.funding_payed()) // 10 + 2) ] for lang in [lc for (lc, _ln) in settings.LANGUAGES] ])
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 [ '/api/include/tag/%d.%s.json', '/api/include/tag/%d.%s.xml', ] for lang in languages ]) flush_ssi_includes([ '/katalog/%s.json' % lang for lang in languages])
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/b/%d/mini.%s.html', '/katalog/b/%d/mini_nolink.%s.html', '/katalog/b/%d/short.%s.html', '/katalog/b/%d/wide.%s.html', '/api/include/book/%d.%s.json', '/api/include/book/%d.%s.xml', ] for lang in languages ])
def flush_includes(self): flush_ssi_includes([ '/chunks/chunk/%s.%s.html' % (self.key, lang) for lang in [lc for (lc, _ln) in settings.LANGUAGES]])
def flush_includes(self): flush_ssi_includes([ '/chunks/chunk/%s.%s.html' % (self.key, lang) for lang in [lc for (lc, _ln) in settings.LANGUAGES] ])
def flush_includes(self): flush_ssi_includes(['/sponsors/page/%s.html' % self.name])
def collection_save(sender, instance, **kwargs): caches[settings.CACHE_MIDDLEWARE_ALIAS].clear() flush_ssi_includes([ '/katalog/%s.json' % lang for lang in [lc for (lc, _ln) in settings.LANGUAGES]])
def collection_delete(sender, instance, **kwargs): flush_ssi_includes([ '/katalog/%s.json' % lang for lang in [lc for (lc, _ln) in settings.LANGUAGES]])