File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 8989from tests .models import (
9090 AutomaticUrl ,
9191 AutomaticUrl2 ,
92+ Bar ,
9293 BooleanFromModelTestModel ,
9394 ChoicesModel ,
9495 CSVExportTestModel ,
@@ -4733,3 +4734,25 @@ def preprocess_rows(rows, **_):
47334734 t = t .bind (request = req ('get' , ** {'order' : 'synthetic' }))
47344735
47354736 assert not t .columns .synthetic .sortable
4737+
4738+
4739+ @pytest .mark .skip ('Validation is only done on the first level, not on nested levels for now' )
4740+ @pytest .mark .django_db
4741+ def test_disallow_sorting_on_non_sortable_columns_that_have_valid_attr__nested ():
4742+ Bar .objects .create (pk = 1 , foo = Foo .objects .create (foo = '1' ))
4743+
4744+ def preprocess_rows (rows , ** _ ):
4745+ for row in rows :
4746+ row .foo .synthetic = 1
4747+ return rows
4748+
4749+ t = Table (
4750+ auto__model = Bar ,
4751+ preprocess_rows = preprocess_rows ,
4752+ columns__synthetic = Column (attr = 'foo__synthetic' ),
4753+ )
4754+
4755+ # This should not crash
4756+ t = t .bind (request = req ('get' , ** {'order' : 'foo__synthetic' }))
4757+
4758+ assert not t .columns .synthetic .sortable
You can’t perform that action at this time.
0 commit comments