Fixed merge conflicts.

This commit is contained in:
Brandon Taylor
2014-12-22 10:27:46 -05:00
25 changed files with 40 additions and 882 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
VERSION = (1, 7, 7) # following PEP 386
VERSION = (1, 7, 8) # following PEP 386
DEV_N = None
+9 -5
View File
@@ -279,7 +279,11 @@ class SortableInlineBase(SortableAdminBase, InlineModelAdmin):
' and SortableStackedInline must inherit from Sortable')
def get_queryset(self, request):
qs = super(SortableInlineBase, self).get_queryset(request)
if VERSION < (1, 6):
qs = super(SortableInlineBase, self).queryset(request)
else:
qs = super(SortableInlineBase, self).get_queryset(request)
if get_is_sortable(qs):
self.model.is_sortable = True
else:
@@ -292,7 +296,7 @@ class SortableInlineBase(SortableAdminBase, InlineModelAdmin):
class SortableTabularInline(TabularInline, SortableInlineBase):
"""Custom template that enables sorting for tabular inlines"""
if VERSION <= (1, 5):
if VERSION < (1, 6):
template = 'adminsortable/edit_inline/tabular-1.5.x.html'
else:
template = 'adminsortable/edit_inline/tabular.html'
@@ -300,7 +304,7 @@ class SortableTabularInline(TabularInline, SortableInlineBase):
class SortableStackedInline(StackedInline, SortableInlineBase):
"""Custom template that enables sorting for stacked inlines"""
if VERSION <= (1, 5):
if VERSION < (1, 6):
template = 'adminsortable/edit_inline/stacked-1.5.x.html'
else:
template = 'adminsortable/edit_inline/stacked.html'
@@ -308,7 +312,7 @@ class SortableStackedInline(StackedInline, SortableInlineBase):
class SortableGenericTabularInline(GenericTabularInline, SortableInlineBase):
"""Custom template that enables sorting for tabular inlines"""
if VERSION <= (1, 5):
if VERSION < (1, 6):
template = 'adminsortable/edit_inline/tabular-1.5.x.html'
else:
template = 'adminsortable/edit_inline/tabular.html'
@@ -316,7 +320,7 @@ class SortableGenericTabularInline(GenericTabularInline, SortableInlineBase):
class SortableGenericStackedInline(GenericStackedInline, SortableInlineBase):
"""Custom template that enables sorting for stacked inlines"""
if VERSION <= (1, 5):
if VERSION < (1, 6):
template = 'adminsortable/edit_inline/stacked-1.5.x.html'
else:
template = 'adminsortable/edit_inline/stacked.html'
+1 -1
View File
@@ -80,7 +80,7 @@ class Sortable(models.Model):
{self.sortable_foreign_key.name: sfk_obj.id})
try:
obj = self._meta.model.objects.filter(**filters)[:1][0]
obj = self.__class__.objects.filter(**filters)[:1][0]
except IndexError:
obj = None
+12 -7
View File
@@ -1,9 +1,13 @@
from .models import Sortable, SortableForeignKey
def check_inheritance(obj):
return issubclass(type(obj), Sortable)
def get_is_sortable(objects):
if objects:
if issubclass(type(objects[0]), Sortable):
if check_inheritance(objects[0]):
if objects.count() > 1:
return True
return False
@@ -11,7 +15,8 @@ def get_is_sortable(objects):
def is_self_referential(cls):
cls_type = type(cls)
sortable_subclass = issubclass(cls_type, Sortable)
sortable_subclass = check_inheritance(cls_type)
# sortable_subclass = issubclass(cls_type, Sortable)
sortable_foreign_key_subclass = issubclass(cls_type, SortableForeignKey)
if sortable_foreign_key_subclass and not sortable_subclass:
return True
@@ -20,10 +25,10 @@ def is_self_referential(cls):
def check_model_is_sortable(cls):
if cls:
if is_self_referential(cls):
objects = cls.model.objects
else:
objects = cls.objects
if check_inheritance(cls):
if is_self_referential(cls):
objects = cls.model.objects
else:
objects = cls.objects
return get_is_sortable(objects.all())
return False