Browse Source

Guests can't sort/filter lists

Rafał Pitoń 10 years ago
parent
commit
60c61cd4eb

+ 2 - 0
misago/templates/misago/threads/list.html

@@ -40,8 +40,10 @@
 
       <div class="table-actions">
         {% include "misago/threads/paginator.html" %}
+        {% if user.is_authenticated %}
         {% include "misago/threads/sort.html" %}
         {% include "misago/threads/show.html" %}
+        {% endif %}
         {% include "misago/threads/reply_btn.html" %}
       </div>
 

+ 7 - 0
misago/threads/views/generic/threadslists.py

@@ -254,6 +254,13 @@ class ForumView(FilterThreadsMixin, OrderThreadsMixin, ThreadsView):
         else:
             forum.subforums = []
 
+        if request.user.is_anonymous():
+            if kwargs.get('sort') or kwargs.get('show'):
+                """we don't allow sort/filter for guests"""
+                kwargs.pop('sort', None)
+                kwargs.pop('show', None)
+                return redirect('misago:forum', **kwargs)
+
         order_by = self.get_ordering(kwargs)
         if self.is_ordering_default(kwargs.get('sort')):
             kwargs.pop('sort')