Added support for stacked inline models.
Added highlighting to sorted inline. Added migrations to add Note class to database. Added SortableInlineBase for checking type of model specified in inline model subclasses Sortable.
This commit is contained in:
1 parent
4e38d8fbe1
commit
971de8423c
18 files changed
+1904
-20
No files matched your search
@@ -1,7 +1,7 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from adminsortable.admin import SortableAdmin, SortableTabularInline
|
||||
from app.models import Category, Project, Credit
|
||||
from adminsortable.admin import SortableAdmin, SortableTabularInline, SortableStackedInline
|
||||
from app.models import Category, Project, Credit, Note
|
||||
|
||||
|
||||
admin.site.register(Category, SortableAdmin)
|
||||
@@ -11,8 +11,12 @@ class CreditInline(SortableTabularInline):
|
||||
model = Credit
|
||||
|
||||
|
||||
class NoteInline(SortableStackedInline):
|
||||
model = Note
|
||||
|
||||
|
||||
class ProjectAdmin(SortableAdmin):
|
||||
inlines = [CreditInline]
|
||||
inlines = [CreditInline, NoteInline]
|
||||
list_display = ['__unicode__', 'category']
|
||||
|
||||
admin.site.register(Project, ProjectAdmin)
|
||||
Binary file not shown.
@@ -0,0 +1,59 @@
|
||||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Adding model 'Note'
|
||||
db.create_table('app_note', (
|
||||
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||
('order', self.gf('django.db.models.fields.PositiveIntegerField')(default=1, db_index=True)),
|
||||
('project', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['app.Project'])),
|
||||
('text', self.gf('django.db.models.fields.CharField')(max_length=100)),
|
||||
))
|
||||
db.send_create_signal('app', ['Note'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Deleting model 'Note'
|
||||
db.delete_table('app_note')
|
||||
|
||||
|
||||
models = {
|
||||
'app.category': {
|
||||
'Meta': {'ordering': "['order', 'id']", 'object_name': 'Category'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}),
|
||||
'title': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
'app.credit': {
|
||||
'Meta': {'ordering': "['order', 'id']", 'object_name': 'Credit'},
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
|
||||
'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}),
|
||||
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['app.Project']"})
|
||||
},
|
||||
'app.note': {
|
||||
'Meta': {'ordering': "['order', 'id']", 'object_name': 'Note'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}),
|
||||
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['app.Project']"}),
|
||||
'text': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
'app.project': {
|
||||
'Meta': {'ordering': "['order', 'id']", 'object_name': 'Project'},
|
||||
'category': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['app.Category']"}),
|
||||
'description': ('django.db.models.fields.TextField', [], {}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'db_index': 'True'}),
|
||||
'title': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['app']
|
||||
Binary file not shown.
@@ -37,8 +37,11 @@ class Project(SimpleModel, Sortable):
|
||||
description = models.TextField()
|
||||
|
||||
|
||||
#registered as an inline on project
|
||||
#registered as a tabular inline on project
|
||||
class Credit(Sortable):
|
||||
class Meta(Sortable.Meta):
|
||||
pass
|
||||
|
||||
project = models.ForeignKey(Project)
|
||||
first_name = models.CharField(max_length=30)
|
||||
last_name = models.CharField(max_length=30)
|
||||
@@ -46,3 +49,14 @@ class Credit(Sortable):
|
||||
def __unicode__(self):
|
||||
return '%s %s' % (self.first_name, self.last_name)
|
||||
|
||||
|
||||
#registered as a stacked inline on project
|
||||
class Note(Sortable):
|
||||
class Meta(Sortable.Meta):
|
||||
pass
|
||||
|
||||
project = models.ForeignKey(Project)
|
||||
text = models.CharField(max_length=100)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.text
|
||||
Binary file not shown.
Reference in new issue
Block a user