Stops sending M2M updates from PgModel objects upon every single update
authorJonathan S. Katz <jonathan.katz@excoventures.com>
Sat, 17 Dec 2011 23:29:13 +0000 (18:29 -0500)
committerJonathan S. Katz <jonathan.katz@excoventures.com>
Sat, 17 Dec 2011 23:29:13 +0000 (18:29 -0500)
Prevents changes from M2M updates from appearing after every single
save to a PgModel derived class. The unfortunate side effect is that
no M2M updates will appear, but this has to do with the context in how
the diff between two objects it taking place.  An expanded note appears in
the explanation to #110

Fixes #110

pgweb/util/bases.py

index 73974896fde87e6d359aa1ddb9d35613f88b14f1..c4573e7dac1ed32b3e47a0e711b72ff3385782d8 100644 (file)
@@ -59,7 +59,6 @@ class PgModel(object):
                        oldobj = self.__class__.objects.get(pk=self.pk)
                except self.DoesNotExist, e:
                        return ('A new %s has been added' % self._meta.verbose_name, self.full_text_representation())
-               
                if hasattr(self,'approved'):
                        # This object has the capability to do approving. Apply the following logic:
                        # 1. If object was unapproved, and is still unapproved, don't send notification
@@ -139,7 +138,7 @@ class PgModel(object):
                        oldobj._get_attr_value(n),
                        n,
                        self._get_attr_value(n),
-               ) for n in fieldlist if not getattr(oldobj,n)==getattr(self,n)])
+               ) for n in fieldlist if oldobj._get_attr_value(n) != self._get_attr_value(n)])
                if not s: return None
                return s