def record_history(self, sender, instance, **kwargs):
"""When a page is published, make a new PublishHistory object"""
from .models import EditHistory, PublishHistory
# Make sure we have the draft version.
if not instance.publisher_is_draft:
instance = publisher_draft
editings = EditHistory.objects.filter(
page_id=instance.id,
published_in__isnull=True,
)
if editings.count() == 0:
# No changes happened, skip!
return
public = instance.publisher_public
user_id = cache.get('cms-user-id')
history = PublishHistory.objects.create(
page=public, user_id=user_id, language=get_language())
history.editings = editings
history.save()
评论列表
文章目录