Added NonSortableCategory and SortableCategoryWidget model classes.
Wired up NonSortableCategory and inline sortable SortableCategoryWidget to sample project admin.master
parent
f33f5e90ed
commit
234a0118db
|
|
@ -1,10 +1,11 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from adminsortable.admin import (SortableAdmin, SortableTabularInline,
|
||||
SortableStackedInline, SortableGenericStackedInline)
|
||||
SortableStackedInline, SortableGenericStackedInline,
|
||||
NonSortableParentAdmin)
|
||||
from adminsortable.utils import get_is_sortable
|
||||
from app.models import (Category, Widget, Project, Credit, Note, GenericNote,
|
||||
Component, Person)
|
||||
Component, Person, NonSortableCategory, SortableCategoryWidget)
|
||||
|
||||
|
||||
admin.site.register(Category, SortableAdmin)
|
||||
|
|
@ -65,3 +66,14 @@ class PersonAdmin(SortableAdmin):
|
|||
list_display = ['__unicode__', 'is_board_member']
|
||||
|
||||
admin.site.register(Person, PersonAdmin)
|
||||
|
||||
|
||||
class SortableCategoryWidgetInline(SortableStackedInline):
|
||||
model = SortableCategoryWidget
|
||||
extra = 0
|
||||
|
||||
|
||||
class NonSortableCategoryAdmin(NonSortableParentAdmin):
|
||||
inlines = [SortableCategoryWidgetInline]
|
||||
|
||||
admin.site.register(NonSortableCategory, NonSortableCategoryAdmin)
|
||||
|
|
|
|||
|
|
@ -116,3 +116,17 @@ class Person(Sortable):
|
|||
|
||||
def __unicode__(self):
|
||||
return '{0} {1}'.format(self.first_name, self.last_name)
|
||||
|
||||
|
||||
class NonSortableCategory(SimpleModel):
|
||||
class Meta(SimpleModel.Meta):
|
||||
verbose_name = 'Non-Sortable Category'
|
||||
verbose_name_plural = 'Non-Sortable Categories'
|
||||
|
||||
|
||||
class SortableCategoryWidget(SimpleModel, Sortable):
|
||||
class Meta(Sortable.Meta):
|
||||
verbose_name = 'Sortable Category Widget'
|
||||
verbose_name_plural = 'Sortable Category Widgets'
|
||||
|
||||
non_sortable_category = SortableForeignKey(NonSortableCategory)
|
||||
|
|
|
|||
Loading…
Reference in New Issue