Added sortable non-online category example.

master
Brandon Taylor 2014-11-08 08:49:07 -05:00
parent bcd328a101
commit daadd190cb
5 changed files with 26 additions and 1 deletions

View File

@ -6,7 +6,7 @@ from adminsortable.admin import (SortableAdmin, SortableTabularInline,
from adminsortable.utils import get_is_sortable
from app.models import (Category, Widget, Project, Credit, Note, GenericNote,
Component, Person, NonSortableCategory, SortableCategoryWidget,
SelfReferentialCategory)
SortableNonInlineCategory, SelfReferentialCategory)
admin.site.register(Category, SortableAdmin)
@ -79,5 +79,6 @@ class NonSortableCategoryAdmin(NonSortableParentAdmin):
admin.site.register(NonSortableCategory, NonSortableCategoryAdmin)
admin.site.register(SortableNonInlineCategory, SortableAdmin)
admin.site.register(SelfReferentialCategory, SortableAdmin)

View File

@ -141,6 +141,21 @@ class SortableCategoryWidget(SimpleModel, Sortable):
return self.title
class SortableNonInlineCategory(SimpleModel, Sortable):
"""Example of a model that is sortable, but has a SortableForeignKey
that is *not* sortable, and is also not defined as an inline of the
SortableForeignKey field."""
class Meta(Sortable.Meta):
verbose_name = 'Sortable Non-Inline Category'
verbose_name_plural = 'Sortable Non-Inline Categories'
non_sortable_category = SortableForeignKey(NonSortableCategory)
def __str__(self):
return self.title
class SelfReferentialCategory(SimpleModel, Sortable):
class Meta(Sortable.Meta):
verbose_name = 'Sortable Referential Category'

View File

@ -123,6 +123,9 @@ class NonSortableCategory(SimpleModel):
verbose_name = 'Non-Sortable Category'
verbose_name_plural = 'Non-Sortable Categories'
def __unicode__(self):
return self.title
class SortableCategoryWidget(SimpleModel, Sortable):
class Meta(Sortable.Meta):
@ -131,6 +134,9 @@ class SortableCategoryWidget(SimpleModel, Sortable):
non_sortable_category = SortableForeignKey(NonSortableCategory)
def __unicode__(self):
return self.title
class SortableNonInlineCategory(SimpleModel, Sortable):
"""Example of a model that is sortable, but has a SortableForeignKey
@ -142,3 +148,6 @@ class SortableNonInlineCategory(SimpleModel, Sortable):
verbose_name_plural = 'Sortable Non-Inline Categories'
non_sortable_category = SortableForeignKey(NonSortableCategory)
def __unicode__(self):
return self.title