Commit ea26ab85 by benjaoming

Anonymous users cannot be used in queries!

parent c619639c
...@@ -8,10 +8,13 @@ class PermissionArticleManagerMixin(object): ...@@ -8,10 +8,13 @@ class PermissionArticleManagerMixin(object):
are included""" are included"""
if user.has_perm('wiki.moderator'): if user.has_perm('wiki.moderator'):
return self.get_query_set() return self.get_query_set()
q = self.get_query_set().filter(Q(other_read=True) | if user.is_anonymous():
Q(owner=user) | q = self.get_query_set().filter(other_read=True)
(Q(group__user=user) & Q(group_read=True)) else:
) q = self.get_query_set().filter(Q(other_read=True) |
Q(owner=user) |
(Q(group__user=user) & Q(group_read=True))
)
return q return q
def can_write(self, user): def can_write(self, user):
...@@ -19,10 +22,13 @@ class PermissionArticleManagerMixin(object): ...@@ -19,10 +22,13 @@ class PermissionArticleManagerMixin(object):
are included""" are included"""
if user.has_perm('wiki.moderator'): if user.has_perm('wiki.moderator'):
return self.get_query_set() return self.get_query_set()
q = self.get_query_set().filter(Q(other_write=True) | if user.is_anonymous():
Q(owner=user) | q = self.get_query_set().filter(other_write=True)
(Q(group__user=user) & Q(group_write=True)) else:
) q = self.get_query_set().filter(Q(other_write=True) |
Q(owner=user) |
(Q(group__user=user) & Q(group_write=True))
)
return q return q
class PermissionArticleManager(PermissionArticleManagerMixin, models.Manager): class PermissionArticleManager(PermissionArticleManagerMixin, models.Manager):
......
...@@ -24,8 +24,7 @@ ...@@ -24,8 +24,7 @@
<div class="tab-content"> <div class="tab-content">
<div class="row-fluid"> <div class="row-fluid">
<div class="span7"> <div class="span7">
<h2>{% trans "Attachments" %}</h2> <p class="lead">{% trans "The following files are available for this article. Copy the markdown tag to directly refer to a file from the article text." %}</p>
<p>{% trans "The following files are available for this article. Copy the markdown tag to directly refer to a file from the article text." %}</p>
{% for attachment in attachments %} {% for attachment in attachments %}
<table class="table table-bordered table-striped" style="width: 100%;"> <table class="table table-bordered table-striped" style="width: 100%;">
<tr> <tr>
......
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