Commit c7aa2e17 by benjaoming

Merge pull request #40 from uAnywhere/master

Fix select_related_common call on EmptyQuerySet (Django 1.5/master), minor optimisation on ACLs (use .exists() instead of bool())
parents 76b06989 4e6cdda8
......@@ -57,7 +57,7 @@ class Article(models.Model):
if user == self.owner:
return True
if self.group_read:
if self.group and user.groups.filter(id=self.group.id):
if self.group and user.groups.filter(id=self.group.id).exists():
return True
if self.can_moderate(user):
return True
......@@ -74,7 +74,7 @@ class Article(models.Model):
if user == self.owner:
return True
if self.group_write:
if self.group and user and user.groups.filter(id=self.group.id):
if self.group and user and user.groups.filter(id=self.group.id).exists():
return True
if self.can_moderate(user):
return True
......
......@@ -60,6 +60,8 @@ class URLPath(MPTTModel):
If the cached ancestors were not set explicitly, they will be retrieved from
the database.
"""
if not self.get_ancestors().exists():
self._cached_ancestors = []
if not hasattr(self, "_cached_ancestors"):
self._cached_ancestors = list(self.get_ancestors().select_related_common() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment