From 98f5da6f5d25e41621c99acdcacca611ce6321e2 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Tue, 10 May 2016 14:15:59 +0200 Subject: [PATCH] Make sure there is a basic inherit_predecessor interface for BaseRevisionMixin even though it's naive --- wiki/models/article.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wiki/models/article.py b/wiki/models/article.py index 82bd329d..8b612d3c 100644 --- a/wiki/models/article.py +++ b/wiki/models/article.py @@ -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 -- 2.45.2