Added Person model with ordering_subset and initial data.
This commit is contained in:
+10
-2
@@ -35,7 +35,12 @@ class SortableAdminBase(object):
|
||||
object_tools block to take people to the view to change the sorting.
|
||||
"""
|
||||
|
||||
if get_is_sortable(self.queryset(request)):
|
||||
if self.model.ordering_subset() is not None:
|
||||
objects = self.model.ordering_subset()
|
||||
else:
|
||||
objects = self.queryset(request)
|
||||
|
||||
if get_is_sortable(objects):
|
||||
self.change_list_template = \
|
||||
self.sortable_change_list_with_sort_link_template
|
||||
self.is_sortable = True
|
||||
@@ -102,7 +107,10 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
|
||||
has_perm = request.user.has_perm('{}.{}'.format(opts.app_label,
|
||||
opts.get_change_permission()))
|
||||
|
||||
objects = self.queryset(request)
|
||||
if self.model.ordering_subset() is not None:
|
||||
objects = self.model.ordering_subset()
|
||||
else:
|
||||
objects = self.queryset(request)
|
||||
|
||||
# Determine if we need to regroup objects relative to a
|
||||
# foreign key specified on the model class that is extending Sortable.
|
||||
|
||||
@@ -43,6 +43,10 @@ class Sortable(models.Model):
|
||||
def model_type_id(cls):
|
||||
return ContentType.objects.get_for_model(cls).id
|
||||
|
||||
@classmethod
|
||||
def ordering_subset(cls):
|
||||
return None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Sortable, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user