Added AttributeForm to elegantly handle all the fields that should be displayed in...
[philo.git] / admin / base.py
1 from django.contrib import admin
2 from django.contrib.contenttypes import generic
3 from philo.models import Tag, Attribute
4 from philo.forms import AttributeForm
5
6
7 COLLAPSE_CLASSES = ('collapse', 'collapse-closed', 'closed',)
8
9
10 class AttributeInline(generic.GenericTabularInline):
11         ct_field = 'entity_content_type'
12         ct_fk_field = 'entity_object_id'
13         model = Attribute
14         extra = 1
15         template = 'admin/philo/edit_inline/tabular_attribute.html'
16         allow_add = True
17         classes = COLLAPSE_CLASSES
18         form = AttributeForm
19         exclude = ['value_object_id']
20
21
22 class EntityAdmin(admin.ModelAdmin):
23         inlines = [AttributeInline]
24         save_on_top = True
25
26
27 class TagAdmin(admin.ModelAdmin):
28         list_display = ('name', 'slug')
29         prepopulated_fields = {"slug": ("name",)}
30
31 admin.site.register(Tag, TagAdmin)