2018-01-21 12:44:00 +00:00
|
|
|
from django.contrib import admin
|
2018-02-25 13:36:38 +00:00
|
|
|
from django import forms
|
2018-01-29 21:34:05 +00:00
|
|
|
from .models import Element, ElementDescription, ElementSeparator
|
2018-01-27 22:12:09 +00:00
|
|
|
|
2018-01-21 12:44:00 +00:00
|
|
|
|
2018-02-25 13:36:38 +00:00
|
|
|
class ElementDescriptionAdminForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = ElementDescription
|
|
|
|
widgets = {
|
|
|
|
'description': forms.widgets.Textarea,
|
|
|
|
}
|
|
|
|
fields = '__all__'
|
|
|
|
|
|
|
|
|
2018-01-21 12:44:00 +00:00
|
|
|
class ElementDescriptionInline(admin.StackedInline):
|
|
|
|
model = ElementDescription
|
2018-02-25 13:36:38 +00:00
|
|
|
form = ElementDescriptionAdminForm
|
2018-01-21 12:44:00 +00:00
|
|
|
extra = 2
|
|
|
|
|
2018-01-27 22:12:09 +00:00
|
|
|
|
2018-01-21 12:44:00 +00:00
|
|
|
class ElementAdmin(admin.ModelAdmin):
|
2018-02-25 15:16:47 +00:00
|
|
|
list_display = ('__str__', 'parent', 'link', 'weight')
|
|
|
|
ordering = ('parent', 'weight')
|
2018-01-21 12:44:00 +00:00
|
|
|
inlines = [ElementDescriptionInline]
|
|
|
|
|
2018-01-27 22:12:09 +00:00
|
|
|
|
2018-01-21 12:44:00 +00:00
|
|
|
admin.site.register(Element, ElementAdmin)
|
2018-01-29 21:34:05 +00:00
|
|
|
admin.site.register(ElementSeparator)
|