Skip to content

Commit

Permalink
variant 2 is better, because reversion.get_for_object() will filter b…
Browse files Browse the repository at this point in the history
…y obj.__class__, too and not only by obj.pk!

So you will get strage errors, if version ID doesn't be a version from the same object!
see also: 9c8bd85#L0L382
  • Loading branch information
jedie committed May 15, 2012
1 parent ed4d0c8 commit 19d7983
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions reversion_compare/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,17 +414,9 @@ def compare_view(self, request, object_id, extra_context=None):
object_id = unquote(object_id) # Underscores in primary key get quoted to "_5F"
obj = get_object_or_404(self.model, pk=object_id)

#----------------------------------------------------------------------
# XXX: Better/less better:
# variant 1:
# version1 = get_object_or_404(Version, pk=version_id1, object_id=unicode(obj.pk))
# version2 = get_object_or_404(Version, pk=version_id2, object_id=unicode(obj.pk))

# variant 2:
queryset = reversion.get_for_object(obj)
version1 = get_object_or_404(queryset, pk=version_id1)
version2 = get_object_or_404(queryset, pk=version_id2)
#----------------------------------------------------------------------

if version_id1 > version_id2:
# Compare always the newest one with the older one
Expand Down

0 comments on commit 19d7983

Please sign in to comment.