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.
parent
651064d3fb
commit
3acd88e8c4
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue