From 1ce6ec3284df63f34ef6872aa022d8389613b3aa Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Wed, 28 Jun 2023 13:39:10 +0100 Subject: [PATCH] Re-do fix for #537 without regression Ignore versions for "None" models, such as where the model has subsequently been deleted (eventchecklistcrew and eventchecklistvehicle). Now it makes sense... --- versioning/versioning.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/versioning/versioning.py b/versioning/versioning.py index af2391e3..59d936c0 100644 --- a/versioning/versioning.py +++ b/versioning/versioning.py @@ -160,15 +160,15 @@ class ModelComparison: # Build some dicts of what we have item_dict = {} # build a list of items, key is the item_pk - if len(new_item_versions) == 0: - return None for version in old_item_versions: # put all the old versions in a list - if version is None or version.object is None: - continue - compare = ModelComparison(old=version._object_version.object, **comparisonParams) - item_dict[version.object_id] = compare + if version._model is None: + continue + compare = ModelComparison(old=version._object_version.object, **comparisonParams) + item_dict[version.object_id] = compare for version in new_item_versions: # go through the new versions + if version._model is None: + continue try: compare = item_dict[version.object_id] # see if there's a matching old version compare.new = version._object_version.object # then add the new version to the dictionary