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:
+14
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user