From: hernani Date: Mon, 25 Apr 2011 01:34:01 +0000 (+0000) Subject: Safer last edited action getter. X-Git-Tag: live~311 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/cbe73973da74989e11e3bb3a75f6c14cbabb3064?ds=sidebyside;hp=cefbe813946f9f9e0108193156eedfd265befc33 Safer last edited action getter. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1002 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/models/node.py b/forum/models/node.py index bf82708..33444c7 100644 --- a/forum/models/node.py +++ b/forum/models/node.py @@ -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()