Commit 8a589bbc by benjaoming

Merge branch 'master' of github.com:benjaoming/django-wiki

parents 3a31f2ce c7aa2e17
...@@ -57,7 +57,7 @@ class Article(models.Model): ...@@ -57,7 +57,7 @@ class Article(models.Model):
if user == self.owner: if user == self.owner:
return True return True
if self.group_read: 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 return True
if self.can_moderate(user): if self.can_moderate(user):
return True return True
...@@ -74,7 +74,7 @@ class Article(models.Model): ...@@ -74,7 +74,7 @@ class Article(models.Model):
if user == self.owner: if user == self.owner:
return True return True
if self.group_write: 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 return True
if self.can_moderate(user): if self.can_moderate(user):
return True return True
......
...@@ -60,6 +60,8 @@ class URLPath(MPTTModel): ...@@ -60,6 +60,8 @@ class URLPath(MPTTModel):
If the cached ancestors were not set explicitly, they will be retrieved from If the cached ancestors were not set explicitly, they will be retrieved from
the database. the database.
""" """
if not self.get_ancestors().exists():
self._cached_ancestors = []
if not hasattr(self, "_cached_ancestors"): if not hasattr(self, "_cached_ancestors"):
self._cached_ancestors = list(self.get_ancestors().select_related_common() ) 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