Added Tag inlines in for ObjectDB admin. Fixed issue with tag addition.

This commit is contained in:
Kelketek 2013-08-04 09:25:15 -05:00
parent b0bf60cda4
commit 1da88deb93
2 changed files with 11 additions and 5 deletions

View file

@ -12,13 +12,15 @@ from src.typeclasses.models import Tag, LiteAttribute
class AttributeInline(admin.TabularInline):
# This class is currently not used, because PickleField objects are not editable.
# It's here for us to ponder making a way that allows them to be edited.
model = Attribute
fields = ('db_key', 'db_value')
extra = 0
class TagInline(admin.TabularInline):
model = Tag
fields = ('db_key', 'db_category', 'db_data')
model = ObjectDB.db_tags.through
raw_id_fields = ('tag',)
extra = 0
class LiteAttributeInline(admin.TabularInline):
@ -26,6 +28,9 @@ class LiteAttributeInline(admin.TabularInline):
fields = ('db_key', 'db_category', 'db_data')
extra = 0
class TagAdmin(admin.ModelAdmin):
fields = ('db_key', 'db_category', 'db_data')
class ObjectCreateForm(forms.ModelForm):
"This form details the look of the fields"
class Meta:
@ -83,7 +88,7 @@ class ObjectDBAdmin(admin.ModelAdmin):
)
#deactivated temporarily, they cause empty objects to be created in admin
#inlines = [AliasInline, AttributeInline]
inlines = [TagInline]
# Custom modification to give two different forms wether adding or not.
@ -125,3 +130,4 @@ class ObjectDBAdmin(admin.ModelAdmin):
admin.site.register(ObjectDB, ObjectDBAdmin)
admin.site.register(Tag, TagAdmin)