Added utility function to check if a model defined as a sortable foreign key inherits from Sortable and if there are more than one objects for that model.

This commit is contained in:
Brandon Taylor
2014-10-24 20:28:36 -04:00
parent 651064d3fb
commit 3acd88e8c4
+14 -2
View File
@@ -1,5 +1,17 @@
from .models import Sortable
def get_is_sortable(objects):
if objects:
if objects.count() > 1:
return True
if issubclass(type(objects[0]), Sortable):
if objects.count() > 1:
return True
return False
def check_model_is_sortable(cls):
if cls:
if issubclass(type(cls), Sortable):
if cls.objects.count() > 1:
return True
return False