Tweaked philo migrations to force contenttype creation after migration 0005 so the...
[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, AttributeInlineFormSet
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         formset = AttributeInlineFormSet
20         exclude = ['value_object_id']
21
22
23 class EntityAdmin(admin.ModelAdmin):
24         inlines = [AttributeInline]
25         save_on_top = True
26
27
28 class TagAdmin(admin.ModelAdmin):
29         list_display = ('name', 'slug')
30         prepopulated_fields = {"slug": ("name",)}
31         search_fields = ["name"]
32
33 admin.site.register(Tag, TagAdmin)