]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/base.py
Applies some of the Justin Grant's patches.
[osqa.git] / forum / models / base.py
index fff741c5297315df21e7ca89346366668a347027..2f934a916f349be0eca77c9c56d0347d7b3944fa 100644 (file)
@@ -35,7 +35,7 @@ class LazyQueryList(object):
 
 class CachedQuerySet(models.query.QuerySet):
     def lazy(self):
 
 class CachedQuerySet(models.query.QuerySet):
     def lazy(self):
-        if len(self.query.extra) == 0:
+        if (not len(self.query.extra)) and (not len(self.query.aggregates)):
             return LazyQueryList(self.model, list(self.values_list('id', flat=True)))
         else:
             return self
             return LazyQueryList(self.model, list(self.values_list('id', flat=True)))
         else:
             return self
@@ -151,10 +151,10 @@ class BaseModel(models.Model):
             (f.name, getattr(self, f.name)) for f in self._meta.fields if self._original_state[f.attname] != self.__dict__[f.attname]
         ])
 
             (f.name, getattr(self, f.name)) for f in self._meta.fields if self._original_state[f.attname] != self.__dict__[f.attname]
         ])
 
-    def save(self, *args, **kwargs):
+    def save(self, full_save=False, *args, **kwargs):
         put_back = [k for k, v in self.__dict__.items() if isinstance(v, models.expressions.ExpressionNode)]
 
         put_back = [k for k, v in self.__dict__.items() if isinstance(v, models.expressions.ExpressionNode)]
 
-        if self.id:
+        if self.id and not full_save:
             self.__class__.objects.filter(id=self.id).update(**self._get_update_kwargs())
         else:
             super(BaseModel, self).save()
             self.__class__.objects.filter(id=self.id).update(**self._get_update_kwargs())
         else:
             super(BaseModel, self).save()