Skip to content

Commit

Permalink
#38 Check type before updating version field (#39)
Browse files Browse the repository at this point in the history
Application may already use `reversion` but not implement `HandleRefModel` in every model under control of reversion. Check the objects type before updating the `version` field.

Co-authored-by: Johann Schmitz <johann.schmitz@dc1.com>
  • Loading branch information
ercpe and Johann Schmitz authored Mar 18, 2024
1 parent b7af826 commit a6aabfd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/django_handleref/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

def handle_version(**kwargs):
for vs in kwargs.get("versions"):
instance = vs.object
instance.version = instance.version + 1
instance.save()
if isinstance(vs.object, HandleRefModel):
instance = vs.object
instance.version = instance.version + 1
instance.save()

reversion.signals.post_revision_commit.connect(handle_version)
except ImportError:
Expand Down

0 comments on commit a6aabfd

Please sign in to comment.