Skip to content

Commit

Permalink
Shows only true missing objects, fixes #34
Browse files Browse the repository at this point in the history
also correctly scopes deleted for followed fields
  • Loading branch information
[email protected] committed Apr 11, 2015
1 parent e9bde74 commit 9c81a09
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions reversion_compare/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def get_many_to_something(self, ids, related_model, is_reverse=False):

missing_objects = []
missing_ids = []
deleted = []

if self.field_name not in self.adapter.follow:
# This models was not registered with follow relations
Expand All @@ -160,9 +161,16 @@ def get_many_to_something(self, ids, related_model, is_reverse=False):
missing_objects = related_model.objects.all().filter(pk__in=missing_ids1)
missing_ids = list(target_ids.difference(set(missing_objects.values_list('pk', flat=True))))

deleted = []
if is_reverse:
deleted = [d for d in reversion.get_deleted(related_model) if d.revision == old_revision]
if is_reverse:
true_missing_objects = []
for o in missing_objects:
for ver in reversion.get_for_object(o):
# An object can only be missing if it actually existed prior to this version
# Otherwise its a new item
if ver.revision.date_created < version.revision.date_created:

This comment has been minimized.

Copy link
@jedie

jedie Jul 23, 2015

Owner

Here is the error "local variable 'version' referenced before assignment" #41 isn't it?

true_missing_objects.append(o)
missing_objects = true_missing_objects
deleted = [d for d in reversion.get_deleted(related_model) if d.revision == old_revision]
return versions, missing_objects, missing_ids, deleted

def get_debug(self):
Expand Down

0 comments on commit 9c81a09

Please sign in to comment.