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.

master
Brandon Taylor 2014-10-24 20:28:36 -04:00
parent 651064d3fb
commit 3acd88e8c4
1 changed files with 14 additions and 2 deletions

View File

@ -1,5 +1,17 @@
from .models import Sortable
def get_is_sortable(objects):
if objects:
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