Added grappelli inlines for contentlets and attributes which become active if grappel...
[philo.git] / admin / base.py
index 0383ad4..cb814b7 100644 (file)
@@ -1,6 +1,8 @@
+from django.conf import settings
 from django.contrib import admin
 from django.contrib.contenttypes import generic
-from philo.models import Attribute, Relationship
+from philo.models import Tag, Attribute
+from philo.forms import AttributeForm, AttributeInlineFormSet
 
 
 COLLAPSE_CLASSES = ('collapse', 'collapse-closed', 'closed',)
@@ -11,19 +13,25 @@ class AttributeInline(generic.GenericTabularInline):
        ct_fk_field = 'entity_object_id'
        model = Attribute
        extra = 1
-       template = 'admin/philo/edit_inline/tabular_collapse.html'
        allow_add = True
+       classes = COLLAPSE_CLASSES
+       form = AttributeForm
+       formset = AttributeInlineFormSet
+       fields = ['key', 'value_content_type']
+       if 'grappelli' in settings.INSTALLED_APPS:
+               template = 'admin/philo/edit_inline/grappelli_tabular_attribute.html'
+       else:
+               template = 'admin/philo/edit_inline/tabular_attribute.html'
 
 
-class RelationshipInline(generic.GenericTabularInline):
-       ct_field = 'entity_content_type'
-       ct_fk_field = 'entity_object_id'
-       model = Relationship
-       extra = 1
-       template = 'admin/philo/edit_inline/tabular_collapse.html'
-       allow_add = True
+class EntityAdmin(admin.ModelAdmin):
+       inlines = [AttributeInline]
+       save_on_top = True
 
 
-class EntityAdmin(admin.ModelAdmin):
-       inlines = [AttributeInline, RelationshipInline]
-       save_on_top = True
\ No newline at end of file
+class TagAdmin(admin.ModelAdmin):
+       list_display = ('name', 'slug')
+       prepopulated_fields = {"slug": ("name",)}
+       search_fields = ["name"]
+
+admin.site.register(Tag, TagAdmin)
\ No newline at end of file