~netlandish/django-wiki

98f5da6f5d25e41621c99acdcacca611ce6321e2 — Benjamin Bach 8 years ago a09f173
Make sure there is a basic inherit_predecessor interface for BaseRevisionMixin even though it's naive
1 files changed, 16 insertions(+), 0 deletions(-)

M wiki/models/article.py
M wiki/models/article.py => wiki/models/article.py +16 -0
@@ 308,6 308,22 @@ class BaseRevisionMixin(models.Model):
        elif settings.LOG_IPS_ANONYMOUS:
            self.ip_address = request.META.get('REMOTE_ADDR', None)

    def inherit_predecessor(self, predecessor):
        """
        This is a naive way of inheriting, assuming that ``predecessor`` is in
        fact the predecessor and there hasn't been any intermediate changes!

        :param: predecessor is an instance of whatever object for which
        object.current_revision implements BaseRevisionMixin.
        """
        predecessor = predecessor.current_revision
        self.previous_revision = predecessor
        self.deleted = predecessor.deleted
        self.locked = predecessor.locked
        self.deleted = predecessor.deleted
        self.locked = predecessor.locked
        self.revision_number = predecessor.revision_number + 1

    class Meta:
        abstract = True