Commits

utr...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed 6c7023f

[full-history]
* Added a filter for specific ID
* Changed "offset" and "revision" to **kwargs arguments

  • Participants
  • Parent commits 15c4c9b
  • Branches full-history

Comments (0)

Files changed (1)

File django/contrib/history/models.py

 
 class ChangeLogManager(models.Manager):
 
-    def get_version(self, object, offset=0):
+    def get_version(self, object, **kwargs):
 	""" 
 	Returns 'current-offset' revision of the 'object' 
 	"""
+	if not kwargs['offset']: offset=0
+
 	ct = ContentType.objects.get_for_model(object)
-	return self.get_query_set().filter(
-	    content_type=ct.id).filter(
-		object_id=object.id)[offset]
+
+	if kwargs['revision']:
+	    return self.get_query_set().filter(
+		content_type=ct.id).filter(
+		    object_id=object.id).filter(
+			pk=revision)[offset]
+	else:
+	    return self.get_query_set().filter(
+		content_type=ct.id).filter(
+		    object_id=object.id)[offset]
 
     def list_history(self, object, **kwargs):
 	"""