Commit 75a05819 by benjaoming

Merge branch 'master' of github.com:benjaoming/django-wiki

parents 6641ed1d 2b28521c
......@@ -85,6 +85,7 @@ The following applications should be listed - NB! it's important to maintain the
'wiki.plugins.attachments',
'wiki.plugins.notifications',
'wiki.plugins.images',
'wiki.plugins.macros',
### Database
......
......@@ -4,6 +4,7 @@ from django.contrib.contenttypes import generic
from django.contrib.auth.models import User, Group
from django.core.cache import cache
from django.db import models
from django.db.models.signals import post_save, pre_delete
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
......@@ -332,3 +333,22 @@ class ArticleRevision(BaseRevisionMixin, models.Model):
ordering = ('created',)
unique_together = ('article', 'revision_number')
######################################################
# SIGNAL HANDLERS
######################################################
# clear the ancestor cache when saving or deleting articles so things like
# article_lists will be refreshed
def _clear_ancestor_cache(article):
for ancestor in article.ancestor_objects():
ancestor.article.clear_cache()
def on_article_save_clear_cache(instance, **kwargs):
_clear_ancestor_cache(instance)
post_save.connect(on_article_save_clear_cache, Article)
def on_article_delete_clear_cache(instance, **kwargs):
_clear_ancestor_cache(instance)
pre_delete.connect(on_article_delete_clear_cache, Article)
......@@ -287,5 +287,5 @@ def on_article_delete(instance, *args, **kwargs):
for child in urlpath.get_children():
child.move_to(get_lost_and_found())
# ...and finally delete the path itself
pre_delete.connect(on_article_delete, Article)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment