apps.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:django-cmsplugin-diff 作者: doctormo 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号