Update sample_project for easy testing sortable and nonsortable inlines
parent
cfcf6b1a46
commit
cbce6debb4
|
|
@ -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,
|
||||||
SortableNonInlineCategory)
|
SortableNonInlineCategory, NonSortableCredit, NonSortableNote)
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Category, SortableAdmin)
|
admin.site.register(Category, SortableAdmin)
|
||||||
|
|
@ -56,8 +56,21 @@ class GenericNoteInline(SortableGenericStackedInline):
|
||||||
extra = 0
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
|
class NonSortableCreditInline(admin.TabularInline):
|
||||||
|
model = NonSortableCredit
|
||||||
|
extra = 1
|
||||||
|
|
||||||
|
|
||||||
|
class NonSortableNoteInline(admin.StackedInline):
|
||||||
|
model = NonSortableNote
|
||||||
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
class ProjectAdmin(SortableAdmin):
|
class ProjectAdmin(SortableAdmin):
|
||||||
inlines = [CreditInline, NoteInline, GenericNoteInline]
|
inlines = [
|
||||||
|
CreditInline, NoteInline, GenericNoteInline,
|
||||||
|
NonSortableCreditInline, NonSortableNoteInline
|
||||||
|
]
|
||||||
list_display = ['__unicode__', 'category']
|
list_display = ['__unicode__', 'category']
|
||||||
|
|
||||||
admin.site.register(Project, ProjectAdmin)
|
admin.site.register(Project, ProjectAdmin)
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,25 @@ class Note(Sortable):
|
||||||
return self.text
|
return self.text
|
||||||
|
|
||||||
|
|
||||||
|
# Registered as a tabular inline on `Project` which can't be sorted
|
||||||
|
class NonSortableCredit(models.Model):
|
||||||
|
project = models.ForeignKey(Project)
|
||||||
|
first_name = models.CharField(max_length=30)
|
||||||
|
last_name = models.CharField(max_length=30)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return '{0} {1}'.format(self.first_name, self.last_name)
|
||||||
|
|
||||||
|
|
||||||
|
# Registered as a stacked inline on `Project` which can't be sorted
|
||||||
|
class NonSortableNote(models.Model):
|
||||||
|
project = models.ForeignKey(Project)
|
||||||
|
text = models.CharField(max_length=100)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.text
|
||||||
|
|
||||||
|
|
||||||
# A generic bound model
|
# A generic bound model
|
||||||
class GenericNote(SimpleModel, Sortable):
|
class GenericNote(SimpleModel, Sortable):
|
||||||
content_type = models.ForeignKey(ContentType,
|
content_type = models.ForeignKey(ContentType,
|
||||||
|
|
@ -97,6 +116,7 @@ class Component(SimpleModel, Sortable):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Person(Sortable):
|
class Person(Sortable):
|
||||||
class Meta(Sortable.Meta):
|
class Meta(Sortable.Meta):
|
||||||
verbose_name_plural = 'People'
|
verbose_name_plural = 'People'
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue