Added sortable non-online category example.
parent
bcd328a101
commit
daadd190cb
|
|
@ -6,7 +6,7 @@ from adminsortable.admin import (SortableAdmin, SortableTabularInline,
|
||||||
from adminsortable.utils import get_is_sortable
|
from adminsortable.utils import get_is_sortable
|
||||||
from app.models import (Category, Widget, Project, Credit, Note, GenericNote,
|
from app.models import (Category, Widget, Project, Credit, Note, GenericNote,
|
||||||
Component, Person, NonSortableCategory, SortableCategoryWidget,
|
Component, Person, NonSortableCategory, SortableCategoryWidget,
|
||||||
SelfReferentialCategory)
|
SortableNonInlineCategory, SelfReferentialCategory)
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Category, SortableAdmin)
|
admin.site.register(Category, SortableAdmin)
|
||||||
|
|
@ -79,5 +79,6 @@ class NonSortableCategoryAdmin(NonSortableParentAdmin):
|
||||||
|
|
||||||
admin.site.register(NonSortableCategory, NonSortableCategoryAdmin)
|
admin.site.register(NonSortableCategory, NonSortableCategoryAdmin)
|
||||||
|
|
||||||
|
admin.site.register(SortableNonInlineCategory, SortableAdmin)
|
||||||
|
|
||||||
admin.site.register(SelfReferentialCategory, SortableAdmin)
|
admin.site.register(SelfReferentialCategory, SortableAdmin)
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,21 @@ class SortableCategoryWidget(SimpleModel, Sortable):
|
||||||
return self.title
|
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 SelfReferentialCategory(SimpleModel, Sortable):
|
||||||
class Meta(Sortable.Meta):
|
class Meta(Sortable.Meta):
|
||||||
verbose_name = 'Sortable Referential Category'
|
verbose_name = 'Sortable Referential Category'
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -123,6 +123,9 @@ class NonSortableCategory(SimpleModel):
|
||||||
verbose_name = 'Non-Sortable Category'
|
verbose_name = 'Non-Sortable Category'
|
||||||
verbose_name_plural = 'Non-Sortable Categories'
|
verbose_name_plural = 'Non-Sortable Categories'
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
|
|
||||||
class SortableCategoryWidget(SimpleModel, Sortable):
|
class SortableCategoryWidget(SimpleModel, Sortable):
|
||||||
class Meta(Sortable.Meta):
|
class Meta(Sortable.Meta):
|
||||||
|
|
@ -131,6 +134,9 @@ class SortableCategoryWidget(SimpleModel, Sortable):
|
||||||
|
|
||||||
non_sortable_category = SortableForeignKey(NonSortableCategory)
|
non_sortable_category = SortableForeignKey(NonSortableCategory)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
|
|
||||||
class SortableNonInlineCategory(SimpleModel, Sortable):
|
class SortableNonInlineCategory(SimpleModel, Sortable):
|
||||||
"""Example of a model that is sortable, but has a SortableForeignKey
|
"""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'
|
verbose_name_plural = 'Sortable Non-Inline Categories'
|
||||||
|
|
||||||
non_sortable_category = SortableForeignKey(NonSortableCategory)
|
non_sortable_category = SortableForeignKey(NonSortableCategory)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.title
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue