mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-02 15:37:18 +02:00
This commit is contained in:
@@ -159,7 +159,7 @@ class BaseTable(tables.Table):
|
||||
columns = None
|
||||
ordering = None
|
||||
|
||||
if self.prefixed_order_by_field in request.GET:
|
||||
if request.user.is_authenticated and self.prefixed_order_by_field in request.GET:
|
||||
if request.GET[self.prefixed_order_by_field]:
|
||||
# If an ordering has been specified as a query parameter, save it as the
|
||||
# user's preferred ordering for this table.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.template import Context, Template
|
||||
from django.test import RequestFactory, TestCase
|
||||
|
||||
@@ -46,6 +47,16 @@ class BaseTableTest(TestCase):
|
||||
prefetch_lookups = table.data.data._prefetch_related_lookups
|
||||
self.assertEqual(prefetch_lookups, tuple())
|
||||
|
||||
def test_configure_anonymous_user_with_ordering(self):
|
||||
"""
|
||||
Verify that table.configure() does not raise an error when an anonymous
|
||||
user sorts a table column.
|
||||
"""
|
||||
request = RequestFactory().get('/?sort=name')
|
||||
request.user = AnonymousUser()
|
||||
table = DeviceTable(Device.objects.all())
|
||||
table.configure(request)
|
||||
|
||||
|
||||
class TagColumnTable(NetBoxTable):
|
||||
tags = columns.TagColumn(url_name='dcim:site_list')
|
||||
|
||||
Reference in New Issue
Block a user