Merge pull request #100 from aptivate/fix_sortable_fk_changelist

Fix sort changelist for objects with sortable fk
master
Brandon Taylor 2015-01-12 22:52:30 -05:00
commit 50b113bac1
2 changed files with 12 additions and 2 deletions

View File

@ -30,5 +30,5 @@ def check_model_is_sortable(cls):
objects = cls.model.objects objects = cls.model.objects
else: else:
objects = cls.objects objects = cls.objects
return get_is_sortable(objects.all()) return get_is_sortable(objects.all())
return False return False

View File

@ -12,7 +12,7 @@ from django.test.client import Client
from adminsortable.models import Sortable from adminsortable.models import Sortable
from adminsortable.utils import get_is_sortable from adminsortable.utils import get_is_sortable
from app.models import Category, Person from app.models import Category, Person, Project
class TestSortableModel(Sortable): class TestSortableModel(Sortable):
@ -176,3 +176,13 @@ class SortableTestCase(TestCase):
self.assertEqual(self.first_person, result, 'Previous person should ' self.assertEqual(self.first_person, result, 'Previous person should '
'be "{0}"'.format(self.first_person)) 'be "{0}"'.format(self.first_person))
def test_adminsortable_change_list_view_loads_with_sortable_fk(self):
category1 = self.create_category(title='Category 3')
Project.objects.create(category=category1, description="foo")
self.client.login(username=self.user.username,
password=self.user_raw_password)
response = self.client.get('/admin/app/project/sort/')
self.assertEquals(response.status_code, httplib.OK,
'Unable to reach sort view.')