Browse Source

Test ACL when deciding if to display private threads link.

Ralfp 12 years ago
parent
commit
199cf16872

+ 7 - 0
misago/acl/permissions/threads.py

@@ -200,6 +200,13 @@ class ThreadsACL(BaseACL):
             return False
             return False
         return queryset
         return queryset
 
 
+    def can_read_threads(self, forum):
+        try:
+            forum_role = self.acl[forum.pk]
+            return forum_role['can_read_threads']
+        except KeyError:
+            return False
+
     def can_start_threads(self, forum):
     def can_start_threads(self, forum):
         try:
         try:
             forum_role = self.acl[forum.pk]
             forum_role = self.acl[forum.pk]

+ 1 - 1
misago/context_processors.py

@@ -19,7 +19,7 @@ def common(request):
             'stopwatch': request.stopwatch.time(),
             'stopwatch': request.stopwatch.time(),
             'user': request.user,
             'user': request.user,
             'version': __version__,
             'version': __version__,
-            'private': Forum.objects.special_model('private'),
+            'private_threads': Forum.objects.special_model('private'),
             'reports': Forum.objects.special_model('reports'),
             'reports': Forum.objects.special_model('reports'),
         }
         }
     except AttributeError:
     except AttributeError:

+ 1 - 1
templates/cranefly/layout.html

@@ -49,7 +49,7 @@
         <ul class="nav navbar-blocks pull-right">
         <ul class="nav navbar-blocks pull-right">
           <li class="user-profile"><a href="{% url 'user' user=user.id, username=user.username_slug %}" title="{% trans %}Go to your profile{% endtrans %}" class="tooltip-bottom"><div><img src="{{ user.get_avatar(28) }}" alt=""> {{ user.username }}</div></a></li>
           <li class="user-profile"><a href="{% url 'user' user=user.id, username=user.username_slug %}" title="{% trans %}Go to your profile{% endtrans %}" class="tooltip-bottom"><div><img src="{{ user.get_avatar(28) }}" alt=""> {{ user.username }}</div></a></li>
           <li><a href="{% url 'alerts' %}" title="{% if user.alerts %}{% trans %}You have new notifications!{% endtrans %}{% else %}{% trans %}Your Notifications{% endtrans %}{% endif %}" class="tooltip-bottom"><i class="icon-asterisk"></i>{% if user.alerts %}<span class="label label-important">{{ user.alerts }}</span>{% endif %}</a></li>
           <li><a href="{% url 'alerts' %}" title="{% if user.alerts %}{% trans %}You have new notifications!{% endtrans %}{% else %}{% trans %}Your Notifications{% endtrans %}{% endif %}" class="tooltip-bottom"><i class="icon-asterisk"></i>{% if user.alerts %}<span class="label label-important">{{ user.alerts }}</span>{% endif %}</a></li>
-          {% if settings.enable_private_threads %}
+          {% if settings.enable_private_threads and acl.forums.can_browse_forum(private_threads) and acl.threads.can_read_threads(private_threads) %}
           <li><a href="#" title="{% if user.unread_pds %}{% trans %}You have new replies in your Private Threads!{% endtrans %}{% else %}{% trans %}Your Private Threads{% endtrans %}{% endif %}" class="tooltip-bottom"><i class="icon-inbox"></i>{% if user.unread_pds %}<span class="label label-important">{{ user.unread_pds }}</span>{% endif %}</a></li>
           <li><a href="#" title="{% if user.unread_pds %}{% trans %}You have new replies in your Private Threads!{% endtrans %}{% else %}{% trans %}Your Private Threads{% endtrans %}{% endif %}" class="tooltip-bottom"><i class="icon-inbox"></i>{% if user.unread_pds %}<span class="label label-important">{{ user.unread_pds }}</span>{% endif %}</a></li>
           {% endif %}
           {% endif %}
           <li><a href="{% url 'newsfeed' %}" title="{% trans %}Your News Feed{% endtrans %}" class="tooltip-bottom"><i class="icon-signal"></i></a></li>
           <li><a href="{% url 'newsfeed' %}" title="{% trans %}Your News Feed{% endtrans %}" class="tooltip-bottom"><i class="icon-signal"></i></a></li>