]> git.openstreetmap.org Git - osqa.git/commitdiff
Safer last edited action getter.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Mon, 25 Apr 2011 01:34:01 +0000 (01:34 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Mon, 25 Apr 2011 01:34:01 +0000 (01:34 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1002 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/models/node.py

index bf82708cdf604644ec0c7a2b5e76a71708d0d9bb..33444c7d678a5cc58d3b653ee2aac2ef7d77246c 100644 (file)
@@ -375,6 +375,18 @@ class Node(BaseModel, NodeContent):
 
         return active_users
 
+    def get_last_edited(self):
+        if not self.last_edited:
+            try:
+                le = self.actions.exclude(action_type__in=('voteup', 'votedown', 'flag'), canceled=True).order_by('-action_date')[0]
+                self.last_edited = le
+                self.save()
+            except:
+                pass
+
+        return self.last_edited
+
+
     def _list_changes_in_tags(self):
         dirty = self.get_dirty_fields()